LambdaLabs / docsy-lambda-docs

3 stars 8 forks source link

Add FAQ: "How do I run my Anaconda environment in my instance?" #99

Closed cbrownstein-lambda closed 1 year ago

cbrownstein-lambda commented 1 year ago
1. Log into the cloud instance:
   my_machine$ ssh ubuntu@<ip address> -i <location of *.pem file>
2. Download anaconda:
   ubuntu@cloud$ wget https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh
3. Install
   ubuntu@cloud$ sh ./Anaconda3-2022.10-Linux-x86_64.sh
4. Activate conda:
   ubuntu@cloud$ eval "$(/home/ubuntu/anaconda3/bin/conda shell.bash hook)"
5. Check your driver version, and which CUDA it supports up to:
   ubuntu@cloud$ nvidia-smi | grep Driver
     | NVIDIA-SMI 515.65.01    Driver Version: 515.65.01    CUDA Version: 11.7     |

6. Create a environment (Make sure the CUDA supports the GPU and the driver).
   CUDA must be 11.1 or higher on Ampere GPUs
   And be the same or lower version that the nvidia driver supports (nvidia-smi).

   Install environment:
   (base) ubuntu@cloud$ conda create --name torch_env pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia

   or for older versions: (CUDA 11.3):
   (base) ubuntu@cloud$ conda create --name torch_11_3 pytorch==1.12.0 torchvision==0.13.0 torchaudio==0.12.0 cudatoolkit=11.3 -c pytorch

   .... wait while it installs ...  NOTE: You could do the install into the persistant storage if you can use the same region each time.

7. Activate the environment
   (base) ubuntu@cloud$ conda activate torch_env

8. Install Jupyter lab
   (torch_env) ubuntu@cloud$ pip install jupyterlab

9. Restart Jupyter on the machine
   (torch_env) ubuntu@cloud$ sudo systemctl stop lambda-jupyter.service
   (torch_env) ubuntu@cloud$ python /home/ubuntu/.local/bin/jupyter-lab --config /home/ubuntu/.jupyter/jupyter_conf.py

10. Reload the Jupyter notebook kernel

Credit: @markwdalton