python-pytorchHow can I install Python PyTorch on Ubuntu using ROCm?
- First, make sure that your system meets the prerequisites for building and running PyTorch on ROCm. You will need to have the following installed:
- Ubuntu 18.04 or higher
- ROCm 3.5 or higher
- Python 3.6 or higher
- GCC 7.4 or higher
- After you have the prerequisites installed, you can install PyTorch on ROCm using the following command:
pip3 install torch-rocm
- After the installation is complete, you can verify that the installation was successful by running the following command:
python3 -c "import torch; print(torch.__version__)"
Output example
1.7.0a0+f6b1b8d
- To use PyTorch with ROCm, you can use the following command:
python3 -m torch.utils.collect_env
- This will display the environment variables that PyTorch needs to use ROCm. You can also check the version of PyTorch that is installed by running the following command:
python3 -c "import torch; print(torch.version.cuda)"
Output example
9.2
- To use PyTorch with ROCm, you will need to set the environment variable
HIP_VISIBLE_DEVICES
to the GPU device ID. This can be done by running the following command:
export HIP_VISIBLE_DEVICES=0
- You can now use PyTorch with ROCm by running the following command:
python3 -m torch.utils.collect_env
Helpful links
More of Python Pytorch
- How can I use Yolov5 with PyTorch?
- How can I use Python, PyTorch, and YOLOv5 to build an object detection model?
- How can I use Python and PyTorch to parse XML files?
- How can I use PyTorch with Python 3.10?
- How can I use Python PyTorch without a GPU?
- How can I use Python and PyTorch together with Xorg?
- How can I use PyTorch with Python 3.11?
- How do I use Pytorch with Python 3.11 on Windows?
- How do I install a Python PyTorch .whl file?
- How can I use Python PyTorch with CUDA?
See more codes...