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 Python and PyTorch together with Xorg?
- How can I optimize a PyTorch model using ROCm on Python?
- How can I use Yolov5 with PyTorch?
- How can I use Python and PyTorch to parse XML files?
- How do I use Pytorch with Python 3.11 on Windows?
- How can I use Python PyTorch with CUDA?
- How can I use Python, PyTorch, and YOLOv5 to build an object detection model?
- How do I use PyTorch with Python version 3.11?
- How can I compare the performance of PyTorch Python and C++ for software development?
- How do I upgrade PyTorch using Python?
See more codes...