> For the complete documentation index, see [llms.txt](https://docs.ccv.brown.edu/oscar/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ccv.brown.edu/oscar/gpu-computing/installing-frameworks-pytorch-tensorflow-jax.md).

# Installing Frameworks (PyTorch, TensorFlow, Jax)

{% hint style="info" %}
Preface: Oscar is a heterogeneous cluster meaning we have nodes with different architecture GPUs (Pascal, Volta, Turing, and Ampere). We recommend building the environment first time on Ampere GPUs with the latest CUDA11 modules so it's backward compatible with older architecture GPUs.
{% endhint %}

In this example, we will install **PyTorch** (refer to sub-pages for TensorFlow and Jax).

**Step 1:** Request an interactive session on a GPU node with Ampere architecture GPUs

`interact -q gpu -g 1 -f ampere -m 20g -n 4`

Here, -f = feature. We only need to build on Ampere once.

**Step 2:** Once your session has started on a compute node, run `nvidia-smi` to verify the GPU and then load the appropriate modules

**Step 3:** Create and activate the virtual environment, unload the pre-loaded modules then load cudnn and cuda dependencies

```bash
module purge
unset LD_LIBRARY_PATH
module load cudnn cuda
```

**Step 4: Create a new virtual environment**

```bash
python -m venv pytorch.venv
source pytorch.venv/bin/activate
```

**Step 5:** Install the required packages

```bash
pip install --upgrade pip
pip install torch torchvision torchaudio
```

The aforementioned will install the latest version of PyTorch with cuda11 compatibility, for older versions you can specify the version by:

```bash
pip install torch torchvision torchaudio
```

**Step 6:** Test that PyTorch is able to detect GPUs

```bash
python
```

```python
>>> import torch
torch.cuda.is_available()
True
>>> torch.cuda.get_device_name(0)
'NVIDIA GeForce RTX 3090'
```

If the above functions return `True` and GPU `model`, then it's working correctly. You are all set, now you can install other necessary packages.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ccv.brown.edu/oscar/gpu-computing/installing-frameworks-pytorch-tensorflow-jax.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
