Paperspace

Paperspace offers very affordable remote machines with GPU, and allows for 150Gb permanent storage (that is mounted as /notebook folder). I find it easier to set up then any other platform. It has many pre-installed deployments like PyTorch, FastAI, Stable Diffusion, and more. It does require monthly subscription that is at the time of writting $8 per month.

SSH commands

To make your life easier before creating any remote instances, copy ssh public key of computers you will be using to access paperspace (like your laptop) to Paperspace SSH keys section (under your account). See this to set up SSH access.

Gradient ML platform

For most of my needs I use free machines on their Gradient ML platform:

image.png

Don’t forget to set auto-shutdown time depending on you need, 6 hours is the max:

image.png

Once the machine is running, the VSCode icon allows to get the URL of the kernel:

image.png image.png

  Copy URL and on the local machine in VSCode navigate to: “Select Kernel”->“Select another Kernel”->“Existing Jupyter Kernel”->“Enter the URL of the running Jupyter server”->“Python3 (ipykernel)”:

image.png image.png

That’s pretty much it; the kernel is now set in the upper right corner of the VSCode:

image.png

Link describes this too.

This is great for majority of my needs, for longer durations one can always restart the machine.

Note again that only files in the /notebook folder are persistent.

Core machines

Core machines are virtual machines that one can SSH into. More on setting SSH connection in VSCode can be found here.

image.png image.png

One must install Python as a VSCode extension:

image.png

For setting up the environment see here.

Shared drive

Shared drive is an good way to share drive across multiple machines HOWEVER, BEWARE(!), shared drive speed is 10-50X SLOWER then the local hard drive. So while convenient since no extra copies of data exist, loading data in batches from shared drive will be a bottleneck to your training (for large models and smaller batch sizes). So ideally data should be copied locally before any training.

Machines do have to be on the same private network, which is created from a network tab on Paperspace Core.

Once private network is created instances MUST be assigned to that private noetwork, this is not a default.

Note there might be a delay for all of this to set up (likely <10 minutes) to be able to ssh into a machine.

Once you ssh, you will need several pieces of information, follow this, these are the commands you will be using:

I’ve used SHARE_FOLDERNAME as /home/paperspace/share:

sudo vim /etc/fstab  # use any editor of your choce btw, add the following line at the end: 
# //YOUR_SHARED_DRIVE_IP/YOURSHARE   SHARE_FOLDERNAME  cifs  user=USERNAME,password=PASSWORD,rw,uid=1000,gid=1000,users 0 0
mkdir SHARE_FOLDERNAME  # if doesn't exist
sudo chown paperspace:paperspace SHARE_FOLDERNAME  # this is needed ONLY if SHARE_FOLDERNAME is outside your home directory 
sudo apt-get update
sudo apt install cifs-utils
sudo mount SHARE_FOLDERNAME  # MUST use sudo here!
df

Also you will have to re-mount the shared drive after the instance is restarted, that takes a second though.

To unmount a drive use umount command:

sudo umount SHARE_FOLDERNAME

Docker container

A docker contain is a great way to set up an environment. Once the docker container is built and running, one can attach to it from VSCode and use it as a remote machine. To do this, install “Remote Development” extension pack, then one can attach the container in VSCode by going to a command pallette (Cmd+Shift+P) and typing “Attach to running container”. If running into a user issue, you need to add user to docker group:

sudo usermod -aG docker $USER

and (maybe, not always) restart the machine.

To see running containers’ info from paperspace machine use:

docker ps

To stop all the docker containers:

docker container stop ID_or_NAME
docker container stop $(docker container ls -aq)

GPU stats

Use nvidia-smi to see GPU stats.