PyTorch not detecting AMD GPU although ROCM installed

OS: Ubuntu 20.04

$ rocm-smi

======================= ROCm System Management Interface =======================
================================= Concise Info =================================
GPU  Temp   AvgPwr  SCLK    MCLK    Fan  Perf  PwrCap  VRAM%  GPU%  
0    46.0c  8.0W    800Mhz  100Mhz  0%   auto  180.0W    2%   0%    
============================= End of ROCm SMI Log ==============================

$ rocminfo | grep 'Name:'
  Name:                    Intel(R) Core(TM) i3-10100 CPU @ 3.60GHz
  Marketing Name:          Intel(R) Core(TM) i3-10100 CPU @ 3.60GHz
  Vendor Name:             CPU                                
  Name:                    gfx1010                            
  Marketing Name:          AMD Radeon RX 5700 XT              
  Vendor Name:             AMD                                
      Name:                    amdgcn-amd-amdhsa--gfx1010:xnack-

However, Pytorch is not able to detect GPU:

$ python3

Python 3.9.16 (main, Mar 8 2023, 14:00:05)

[GCC 11.2.0] :: Anaconda, Inc. on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import torch

>>> print("GPU available:", torch.cuda.is_available())

GPU available: False

What’s going wrong here?

What is your pytorch and ROCm versions? Not all versions of ROCm and not all AMD GPUs are supported. Please see this link for details:

OS Version: Ubuntu 20.04 LTS
PyTorch Version: 2.0
ROCM version: 5.0.2

Are they compatible?

$ python -c "import torch; print(torch.__version__)"
$ apt show rocm-libs -a

Package: rocm-libs


Priority: optional

Section: devel

Maintainer: ROCm Libs Support <>

Installed-Size: 13.3 kB

Depends: hipblas, hipfft, hipsolver, hipsparse, miopen-hip, rccl, rocalution, rocblas, rocfft, rocrand, rocsolver, rocsparse, rocm-core, hipblas-dev, hipcub-dev, hipfft-dev, hipsolver-dev, hipsparse-dev, miopen-hip-dev, rccl-dev, rocalution-dev, rocblas-dev, rocfft-dev, rocprim-dev, rocrand-dev, rocsolver-dev, rocsparse-dev, rocthrust-dev


Download-Size: 898 B

APT-Sources: ubuntu/main amd64 Packages

Description: Radeon Open Compute (ROCm) Runtime software stack