---
# System prepended metadata

title: Anaconda Tensorflow and Pytorch

---

# Anaconda Tensorflow and Pytorch

## Tensorflow
https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/
```
conda env list
conda create -n tf-gpu tensorflow-gpu
conda activate tf-gpu
conda list
conda deactivate
conda env remove -n pytorch-gpu
```

## Pytorch
```
conda create -n pytorch-gpu2 python=3.9
conda activate pytorch-gpu2
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
(check the website(https://pytorch.org/))
conda install -c conda-forge gym
conda install -c conda-forge gym-atari
conda install -y -c conda-forge pybox2d
conda install -c conda-forge tensorboard
conda list  #check package
conda deactivate
```

## Mix
```
conda create -n breakout tensorflow-gpu
conda activate breakout
conda install -c conda-forge atari_py
wget http://www.atarimania.com/roms/Roms.rar
unrar x Roms.rar .
python -m atari_py.import_roms ROMS
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
(check the website(https://pytorch.org/))
pip install nvitop
```

## Troubleshoot
1. 'GLIBCXX_3.4.30' not found

do:
```
conda install -c conda-forge gcc=12.1.0
```

2. Could not create GL context
```
pyglet.gl.ContextException: Could not create GL context
```
do:
```
conda install -c conda-forge libstdcxx-ng
```

# Test
```
import torch
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

print(torch.cuda.is_available())
print(torch.cuda.device_count())
print(torch.cuda.current_device())
print(torch.cuda.get_device_name(0))


import tensorflow as tf

tf.test.is_gpu_available()
```
