Setting up Deep Learning Environment

"Isolating Python environments with Conda without hassle"
07 May 2024

If you have not installed Conda, you can download it from here.

Make sure not to install Keras and PyTorch in the same environment. This is because they have different dependencies and versions that might conflict with each other.

Keras

First, create a Conda Environment.

conda create -n tensorflow python=3.9
conda activate tensorflow

Then, install cudnn and cuda.

conda install -c conda-forge cudatoolkit=11.2.2 cudnn=8.1.0

Finally, install Keras by installing Tensorflow. Make sure to specify which versions to install. Otherwise, you would notice any kind of incompatility issues.

pip install --upgrade pip
pip install --user tensorflow==2.5.0 matplotlib==3.6 scipy==1.10

Check if the GPU is detected by TensorFlow.

import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))

PyTorch

Create a new Conda Environment for PyTorch.

conda create -n pytorch python=3.10
conda activate pytorch

Install necessary packages for PyTorch.

pip install torch torchvision torchaudio

Check if the GPU is detected by PyTorch.

import torch
print(torch.cuda.is_available())