This article is a memorandum about building an environment for kaggle in a local environment. Since there are many articles on gcp on the net, it is for those who want to try it locally for the time being.
--Those who want to do kaggle in a local environment --For those who want to create a comfortable environment using vscode
In this article, we will use the remote container of vscode. If you want to do it with gcp, please refer to other articles.
My environment is Ubuntu 20.4. We cannot guarantee that it will work in other environments, but if you are careful about how to mount it, you should be able to do it without problems. For windows, please include wsl. Reference: (https://qiita.com/matarillo/items/61a9ead4bfe2868a0b86)
~ / .kaggle /
.This will create a comfortable environment. I will explain in order.
Please download the one suitable for each OS from Official.
Build according to the article. It will take more than an hour, so please be patient. If you don't use gpu, change --gpu.
Please install the one in the image below.
Select Remote Explorer (a mark like the display on the left) and move the cursor next to CONTAINER to see the + mark. Click new container to select open folder in container, select the docker folder you just git cloned, and select the Docker file. You can also open it in the same way by selecting the green mark at the bottom left.
~ / .kaggle /
.Select edit profile from the official kaggle profile and select create New API Token to download kaggle.json. If you are using the kaggle command from terminal, ~ / .kaggle has been created, so use the cp command etc. to raise kaggle.json in ~ / .kaggle. If you are not running it, you can create your own directory.
If you hit the kaggle command as it is, a warning will be issued. You need to change the permissions of kaggle.json. Enter the following command.
chmod 600 ~/.kaggle/kaggle.json
### 6. Edit the mount destination of .devcontainer / devcontainer.json. Edit extensions if necessary.
At this point, you can run docker, but you can't access local directories other than under docker-python.
It's better to make docker-python a working directory, but I have a working directory for kaggle so I'll make it accessible.
Please change the following code to the location in each working directory and write it in .devcontainer / devcontainer.json.
"mounts": [ "source=/home/artela/works/kaggle,target=/root/kaggle/,type=bind" , "source=/home/artela/.kaggle/,target=/root/.kaggle/,type=bind"],
source points to the local directory, and target describes the access method.
For example, you can access `/ home / artela / works / kaggle` by hitting the following command. The result of ls is empty because everything disappeared when I rebuilt the environment, and if there is something, it should be displayed by ls.
![Screenshot from 2020-11-19 16-01-46.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/545911/f0e22081-1a3c-f852-f491-01b535255469.png)
I don't recommend it, but if you add `source = / home / user /, target = / root /`, you will be able to access all directories.
# Finally
We do not guarantee the operation because we only made it ourselves. If you find something difficult to understand or make a mistake, it would be helpful if you could point it out.
Finally, I will post a twitter account.
Please follow me if you like.
https://twitter.com/Artela_ML
Recommended Posts