In this course, we will use pytorch for Deep Learning. Deep Learning benefits highly from acceleration using a Graphical Processing Unit (GPU). You will have access to computers with GPUs either from Campux Machines ( = any machine from the school that you can connect to using your IMT credentials. That includes the machines in the classroom) or from your Personal Laptop. In the machine with GPUs you will be using, we already have downloaded the dataset you need and installed pytorch and some other useful libraries in the effdl-venv virtual environment.
Every binome will be assigned a computer with a GPU for the whole course.
- Follow one of the two step-by-step guides below to see how to connect to these computers remotely using VS code, either on Campux Machines (recommended) or on your Personal Machines (advanced).
- Once you are connected remotely, open a terminal window in VS Code.
- Activate the python environment
effdl-venv(to be done at each connection!):
source /opt/img/effdl-venv/bin/activate- Run your script:
python3 myscript.py
By default you have access to your /home directory from the school, but as it is on the network it will be slower.
In order to have a faster data access, create a directory in /users/local
Remember this is an internal hard drive with limited capacity, and should only be used for temporary results. Always save your valuable code / results in a secure place.
When saving network weights (checkpoints, in ‘pt’ or ‘pth’ format) , also use /users/local as they can be very large files.
In this course you will be using the CIFAR10 dataset to train and test your model. We have downloaded CIFAR10 in the following folder: /opt/img/effdl-cifar10/
Remember to specify this path when you need to access the dataset (instead of dowloading it from scratch!)
VS Code used for this tutorial: 1.64.2
- Install VS Code Extension named
Remote Development. - Hit F1 key and go to
Remote-SSH: Connect To Host... - Enter your pc id:
sl-tp-br-xxx.imta.fr - Enter your password when prompted
- If asked about fingerprints, hit
Continue - You should have a green rectangle with
SSH: sl-tp-br-xxxon the bottom left corner of your screen. If you don't or got an error along the way, call the teacher for help.
VS Code used for this tutorial: 1.64.2
-
Install an OpenSSH compatible SSH client
-
Install VS Code Extension named
Remote Development. -
Hit F1 key and go to
Remote-SSH: Open Configuration File.... Click on the first line proposed.- On Linux or Mac, add these lines to the file (replace YOUR_LOGIN by your own username):
Host brain1.imt User YOUR_LOGIN Compression yes HostName sl-tp-br-xxx.imta.fr- On Windows, add these lines to the file (replace YOUR_LOGIN by your own username):
Host brain1.imt User YOUR_LOGIN Compression yes HostName sl-tp-br-xxx.imta.fr -
Hit F1 key and go to
Remote-SSH: Connect To Host... -
Select
brain1.imt -
Enter passwords when prompted
-
If asked about fingerprints, hit
Continue -
You should have a green rectangle with
SSH: sl-tp-br-xxx.imta.fron the bottom left corner of your screen. If you don't or got an error along the way, call the teacher for help.
First, you need to check whether your computer has a NVIDIA GPU or not. If it does, you will need to install CUDA, and specify the CUDA version when installing pytorch.
If you have an NVIDIA GPU, install CUDA 11.0: https://developer.nvidia.com/cuda-11.0-download-archive
- Download executable (Windows - x86_64 - 10 - exe)
- Launch installer
- Default installation path
- Express install
- NO NEED TO INSTALL VISUAL STUDIO (tick checkbox "I understand, and wish to continue installation regardless")
- Download and execute installer https://www.python.org/downloads/.
- When asked, check
Add Python to PATH. - Install
To install PyTorch with pip, on the interface here : https://pytorch.org/get-started/locally/#start-locally, select Stable build, Windows OS Pip Package, Python language, and 11.0 version of CUDA. It will give you a command line for the python installation (e.g. pip install torch===1.7.1+cu110 torchvision===0.8.2+cu110 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html). Copy Paste & Execute in Windows Powershell (Start - Windows PowerShell). It will install Pytorch in your python environment.
Download and install https://code.visualstudio.com/download.
Now open a python script (.py file) and write the following :
import torch
x = torch.rand(5, 3)
print(x)VS Code will propose you to install recommended extensions. Install Python extension. Then, your python environment should be recognized. Try and run this code which should display a randomly initialized tensor.
For example, install matplotlib using Windows PowerShell : pip install matplotlib
The latest nvidia drivers can be installed using the command line. For Ubuntu it should be :
sudo apt install nvidia-driver-460We recommend installing Miniconda, as it significantly simplifies the installation setup. Installation steps are here.
We recommend using Python 3.8. At the end of conda installation, make sure to add the conda paths to the .bashrc (it is explicitely asked).
Install pytorch with Conda (this will also install cuda necessary interfaces), on the interface here : https://pytorch.org/get-started/locally/#start-locally, select Stable build, Linux OS Conda Package, Python language, and 11.0 version of CUDA. It will give you a command line for the python installation (e.g. conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch). Run this command line in the terminal.
Download and install https://code.visualstudio.com/download.
Now open a python script (.py file) and write the following :
import torch
x = torch.rand(5, 3)
print(x)VS Code will propose you to install recommended extensions. Install Python extension. Then, your python environment should be recognized. Try and run this code which should display a randomly initialized tensor.
For example, install matplotlib using a terminal : pip install matplotlib