...
| Code Block | ||||
|---|---|---|---|---|
| ||||
# create a conda environment called ML with a spcecific Python version, e.g. 3.12
$ conda create -n ML python=3.12
# activate the environment
$ conda activate ML
# install packages, note that installing tensorflow-gpu and keras also installs many number of extra libraries such as CUDA toolkit, cuDNN (CUDA Deep Neural Network library), Numpy, Scipy, Pillow
(ML) $ conda install tensorflow-gpu keras
# (OPTIONAL) cudatoolkit is installed automatically while installing keras and tensorflow-gpu, but if you need a specific (or latest) version run below command.
(ML) $ conda install -c anaconda cudatoolkit |
Using pip
| Code Block | ||||
|---|---|---|---|---|
| ||||
# create a python environment $ python3 -m venv .venv # activate this environment $ source .venv/bin/activate # upgrade pip (.venv) $ python3 -m pip install --upgrade pip # install tensorflow packages, note that the GPU version of tensorflow requires the installation of the CUDA toolkit, as well as other libraries such as cuDNN (CUDA Deep Neural Network library). (.venv) $ python3 -m pip install 'tensorflow[and-cuda]' # install keras (.venv) $ python3 -m pip install keras # install pytorch, note that the url needs to be specified to work with a specific version of CUDA, in this case 12.8 (.venv) $ python3 -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128 |
...