Kaggle environment construction using official Docker and vscode

Article content

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 find this article helpful

--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)

procedure

  1. First, download vscode
  2. [This article](https://vasteelab.com/2020/06/08/kaggle%E3%81%AE%E7%92%B0%E5%A2%83%E3%82%92docker%E3%81 % A7% E5% 86% 8D% E7% 8F% BE /), git clone and build.
  3. Install the remote container from the vscode extension.
  4. From remote container, select open folder in container and select Docker.
  5. Place kaggle.json in ~ / .kaggle /.
  6. Edit the mount destination of .devcontainer / devcontainer.json. Edit extensions if necessary.

This will create a comfortable environment. I will explain in order.

1. First, download vscode

Please download the one suitable for each OS from Official.

2. [This article](https://vasteelab.com/2020/06/08/kaggle%E3%81%AE%E7%92%B0%E5%A2%83%E3%82%92docker%E3%81 % A7% E5% 86% 8D% E7% 8F% BE /), git clone and build.

Build according to the article. It will take more than an hour, so please be patient. If you don't use gpu, change --gpu.

3. Install the remote container from the vscode extension.

Please install the one in the image below. Screenshot from 2020-11-19 15-38-05.png

4. From remote container, select open folder in container and select Docker.

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. Screenshot from 2020-11-19 15-41-41.png You can also open it in the same way by selecting the green mark at the bottom left.

5. Place kaggle.json in ~ / .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

Kaggle environment construction using official Docker and vscode
Docker environment construction
Docker + DynamoDB local + C ++ environment construction and practice
Rails Docker environment construction
A reminder of Docker and development environment construction
Construction of data analysis environment using Docker (personal memorandum)
MySQL 5.7 (Docker) environment construction memo
Redmine (Docker) environment construction memo
[Docker] Rails 5.2 environment construction with docker
Docker × Spring Boot environment construction
[Docker] postgres, pgadmin4 environment construction
React environment construction with Docker
Easy environment construction of MySQL and Redis with Docker and Alfred
Rails + MySQL environment construction with Docker
Node.js environment construction with Docker Compose
Environment construction with Docker for beginners
Laravel + Docker Laradock usage environment construction
Build PlantUML environment with VSCode + Docker
Rails on Docker environment construction procedure
[Environment construction with Docker] Rails 6 & MySQL 8
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
Create a web environment quickly using Docker
SQL statement learning ~ Environment construction ~ Docker + MySQL
GPU environment construction with Docker [October 2020 version]
Rails environment construction with Docker (personal apocalypse)
Building Rails 6 and PostgreSQL environment with Docker
Sapper × Go (echo) × Docker development environment construction
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Rails API server environment construction using docker-compose
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Spring Boot + Docker Java development environment construction
Laravel + MySQL + phpMyadmin environment construction with Docker
[Environment construction] Docker startup error! Steps to enable Hyper-V and start Docker again
Install Docker and create Java runtime environment
Environment construction summary with rvm and postgresql
Minimal Java environment construction and Hello World
Spring Boot environment construction with Docker (January 2021 version)
Environment construction procedure for using PowerMock with JUnit
Protobuf and gRPC C ++ environment construction on Ubuntu 18.04
(Basic authentication) environment variables in rails and Docker
Environment construction command memo with Docker on AWS
[Ubuntu 18.04] Environment construction for using PyTorch with RTX3090
Rails6 [API mode] + MySQL5.7 environment construction with Docker
Simple installation of nginx and Docker using ansible
Development environment construction using IntelliJ IDEA + Maven + Tomcat 9
[Note] Struts2 environment construction using Gradle in Eclipse
Docker on Ubuntu18.04 on WSL2 and VSCode installation instructions
Rails development environment created with VSCode and devcontainer
Prepare a scraping environment with Docker and Java
Make Volume faster when using Docker with vscode.
IntelliJ + Docker (APP + DB) + SpringBoot (Maven) environment construction
React + Django + Nginx + MySQL environment construction with Docker
Support out of support in docker environment using centos6
Build a development environment for Docker, java, vscode
Django development environment construction using Docker-compose (personal memorandum)
Wordpress local environment construction & development procedure with Docker
Install Ubuntu 20.04 in virtual box on windows10 and build a development environment using docker
Environment construction method and troubleshooter at the time of joint development (rails, docker and github)
Environment construction of keras and tensorflow, jupyter lab by docker and connection to jupyter by port forwarding
[Java] Environment construction
Java environment construction