gpu를 활용해 코드를 작성하던 도중, plot에 cupy로 작성한 배열이 출력되지 않는 오류가 발생했다.

찾아본 결과 cupy 배열은 matplot에 적용이 되지 않는 것이었다.

 

이를 해결하기 위해 cupy를 numpy로 바꾸는 코드를 적용하여 문제를 해결하였다.

https://docs.cupy.dev/en/stable/reference/generated/cupy.asnumpy.html

import cupy as cp
import matplotlib.pyplot as plt

def test_function(x):
    y = x * 10
    return(y)

x = cp.array([0.1, 0.2, 0.3, 0.4, 0.5])
y = test_function(x)
print(y)

plt.plot(cp.asnumpy(y))
plt.show()

 

1) 설치

https://docs.cupy.dev/en/latest/install.html

 

 

2) 오류 발생

(1)

cupy is not correctly installed. if you are using wheel distribution (cupy-cudaxx), make sure that the version of cupy you installed matches with the version of cuda on your host. also, confirm that only one cupy package is installed: $ pip freeze if you are building cupy from source, please check your environment, uninstall cupy and reinstall it with: $ pip install cupy --no-cache-dir -vvvv

이 문제에 대해서는 anaconda에 cupy를 따로 설치해야 할 것이라 판단하여

$ conda install -c conda-forge cupy

코드 실행

 

(2)

CUDADriverError: CUDA_ERROR_UNSUPPORTED_PTX_VERSION: the provided PTX was compiled with an unsupported toolchain.

https://forums.developer.nvidia.com/t/provided-ptx-was-compiled-with-an-unsupported-toolchain-error-using-cub/168292

드라이버 업데이트 수행

 

nvidia geforce experience를 활용, 그래픽카드 드라이버 업데이트

 

+ Recent posts