Articles » PyTorch guide

How to Install PyTorch and Verify CUDA on a Cloud GPU

A current PyTorch container is usually the easiest route because it already combines compatible framework and CUDA libraries. Manual installation requires the NVIDIA driver, Python, PyTorch build, and compiled extensions to agree.

Inspect the environment

nvidia-smi
python3 --version
python3 -m pip --version

If nvidia-smi fails, fix instance or container GPU access before changing Python packages.

Create an isolated environment

python3 -m venv /workspace/venv
source /workspace/venv/bin/activate
python -m pip install --upgrade pip

Use the command produced by the official PyTorch selector for the current stable release and compute platform.

Verify CUDA from Python

python -c "import torch; print(torch.__version__); print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'no GPU')"

Then run a real operation rather than relying only on package import:

python -c "import torch; a=torch.randn(4096,4096,device='cuda'); b=a@a; torch.cuda.synchronize(); print(float(b[0,0]))"

Troubleshooting

Record reproducibility details

python -m pip freeze > requirements-lock.txt
nvidia-smi > nvidia-smi.txt

Keep these with the training configuration. Continue with our cloud GPU benchmark checklist.