DLCompiler/OpenCL

WSL2 Ubuntu 24.04 NVIDIA CUDA Toolkit OpenCL 세팅 최종 정리

melitina 2025. 7. 11. 17:05

Windows 기능 켜기/끄기

https://21june.tistory.com/2

 

[딥러닝 환경 세팅] 윈도우에서 Tensorflow GPU 환경 구성하기 (WSL2, CUDA, Anaconda)

최근에 딥러닝을 공부하고 있습니다. 어느 정도 공부가 되어 실전에서 사용하려고 하니 GPU 세팅이 안되있어서 성능이 좋지 않았습니다. 포스팅된 내용들로 하는데 잘 안되더군요. 살펴보니 Tenso

21june.tistory.com

 

NVIDIA Driver

nvidia-smi

https://www.nvidia.com/en-us/drivers/

 

Download The Latest Official NVIDIA Drivers

Download the latest official NVIDIA drivers to enhance your PC gaming experience and run apps faster.

www.nvidia.com

 

 

 

 

CUDA Toolkit

NVIDIA Driver & CUDA Toolkit 버전 호환 확인

https://xoft.tistory.com/85

 

[Ubuntu] Pytorch 설치 : 버전 호환 CUDA & python

Pytorch를 pip로 설치하면 간단 할 것 같은데, 막상 설치하려고 하면 Pytorch버전에 따라 CUDA 버전, python 버전을 고려해야하고, CUDA 버전은 그래픽카드를 고려해야합니다. 이 글에서는 Pytorch 버전에 따

xoft.tistory.com

 

key

https://docs.nvidia.com/cuda/wsl-user-guide/index.html#cuda-support-for-wsl2

 

1. NVIDIA GPU Accelerated Computing on WSL 2 — CUDA on WSL 12.9 documentation

6.1. Notice This document is provided for information purposes only and shall not be regarded as a warranty of a certain functionality, condition, or quality of a product. NVIDIA Corporation (“NVIDIA”) makes no representations or warranties, expressed

docs.nvidia.com

 

install

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=deb_local

 

CUDA Toolkit 12.1 Downloads

Get the latest feature updates to NVIDIA's proprietary compute stack.

developer.nvidia.com

 

환경변수

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#mandatory-actions

 

CUDA Installation Guide for Linux — Installation Guide for Linux 12.9 documentation

1. Overview The NVIDIA CUDA Installation Guide for Linux provides comprehensive instructions for installing the CUDA Toolkit across multiple Linux distributions and architectures. CUDA® is NVIDIA’s parallel computing platform that enables dramatic perfo

docs.nvidia.com

 

https://velog.io/@ssw9999/WSL2-Cuda-Setting

 

WSL2 CUDA Setting

WSL2 CUDA Setting

velog.io

 

https://m.blog.naver.com/lcs5382/223476471122

 

(WSL2) CUDA 12.6, CuDNN 9.3.0 설치

cuda 설치 https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x...

blog.naver.com

 

 

 

 

opencl-headers : CUDA Toolkit에 헤더 파일이 없음

https://letni.tistory.com/17

 

Linux NVIDIA OpenCL에서 CL/cl.h를 못 찾을때

우선 NVIDIA 드라이버와 CUDA가 정상적으로 깔려있다면 기본적은 OpenCL은 설치가 끝난것 임 해당 파일이 있는지 확인해보려면 다음과 같이 하면됨 find / -iname cl.h 2>/dev/null 일단 해당 파일이 있어야

letni.tistory.com

 

https://stackoverflow.com/questions/7542808/how-to-compile-opencl-on-ubuntu

 

https://forums.developer.nvidia.com/t/missing-opencl-icd-header-files-like-opencl-opencl-h-installing-from-propreitary-driver-package/113224/3

 

Missing OpenCL ICD header files (like OpenCL/opencl.h) installing from propreitary driver package

Yes I’m using Ubuntu, but still running Ubuntu 16 (Xenial) with more recent Ubuntu 5 Kernel. I can’t install nvidia-icd or driver package as these don’t support this kernel version in the released versions provided for Ubuntu 16. For my understanding

forums.developer.nvidia.com

 

 

 

sudo apt install libpocl-dev

(원래 GPU에서 돌려야 하는데 걍 CPU에서도 실행될 수 있도록 차선책으로 하는 것 같다...)

clinfo에 뜨는게 있어야 OpenCL도 돌아간다

 

네! 아래에서 명령어와 해당 패키지에 대해 쉽게 설명드릴게요.

sudo apt install libpocl-dev 설명

1. 명령어 의미

  • sudo
    : 관리자 권한(슈퍼유저)으로 실행한다는 뜻입니다.
  • apt install
    : Ubuntu 등 Debian 계열 리눅스에서 소프트웨어(패키지)를 설치하는 명령입니다.
  • libpocl-dev
    : POCL(OpenCL의 CPU 소프트웨어 구현) 개발용 라이브러리 패키지입니다.

2. libpocl-dev란?

  • **POCL (Portable Computing Language)**는 CPU(일반 프로세서)나 일부 하드웨어에서 OpenCL(병렬 컴퓨팅용 표준)을 사용할 수 있도록 해주는 소프트웨어 라이브러리입니다.
  • libpocl-dev 패키지는
    OpenCL 프로그램을 CPU에서 실행하거나, OpenCL 앱을 개발/컴파일할 때 필요한 헤더 파일과 개발용 라이브러리 등을 제공합니다.

3. 언제 사용하나요?

  • 내 시스템에 NVIDIA, AMD 등 GPU가 없거나, GPU OpenCL이 동작하지 않는 환경에서 OpenCL 기반 코드를 CPU에서라도 테스트·실행하고 싶을 때
  • OpenCL을 지원하는 모든 하드웨어 없이, 소프트웨어적으로 OpenCL을 공부・실습하거나 개발할 때

4. 설치 효과

  • OpenCL 플랫폼이 CPU에서도 동작하게 되므로,
    clinfo 결과에 "POCL"이라는 플랫폼이 추가로 보이게 됩니다.
  • OpenCL 앱을 컴파일할 때 빌드가 원활해지고, CPU로 OpenCL 디바이스를 사용할 수 있습니다.

⚡ 정리

sudo apt install libpocl-dev는
OpenCL을 CPU에서 쓸 수 있도록 해주는 POCL(OpenCL의 범용 CPU 구현) 개발용 라이브러리 설치 명령입니다.
GPU가 없거나 OpenCL이 잘 인식되지 않을 때 fallback(대체), 테스트 용도 등으로 자주 사용합니다.

궁금한 점이나 추가 설명이 필요하면 언제든 물어보세요! 😊

 

 

 

아직 시도 X but GPU 인식 가능성

https://discourse.mc-stan.org/t/tutorial-on-running-stan-code-on-wsl/38850

 

Tutorial on running STAN code on WSL

I am delighted to share my recent breakthrough in enabling GPU acceleration for STAN computations on WSL (Windows Subsystem for Linux). After persistent challenges with OpenCL implementation, I’ve successfully resolved this issue and would like to docume

discourse.mc-stan.org

 

https://discourse.mc-stan.org/t/running-stan-on-the-gpu-with-opencl-on-wsl-seeking-assistance/36149/11

 

Running Stan on the GPU with OpenCL on WSL: Seeking Assistance

@mippeqf Thank you for your reply. I’m relieved to hear that my path settings seem to be correct. Just to be thorough, here are my PATH and LD_LIBRARY_PATH settings: $ echo $PATH /home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/usr/local/c

discourse.mc-stan.org

 

 

 

 

Docker 환경

===========================
사용된 도커 이미지 : PyTorch 2.3.1 (CUDA 12.1)
# Miniforge 설치
$ wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
$ bash Miniforge3-$(uname)-$(uname -m).sh -b
$ ~/miniforge3/condabin/conda init
$ source ~/.bashrc
# Mamba를 사용하여 PoCL 설치
$ mamba install pocl
$ mkdir -p /etc/OpenCL/vendors
$ ln -s ~/miniforge3/etc/OpenCL/vendors/pocl.icd /etc/OpenCL/vendors/pocl.icd
# OpenCL 라이브러리 및 clinfo 설치
# apt update
# apt install -y clinfo ocl-icd-libopencl1 ocl-icd-dev ocl-icd-opencl-dev
이후 clinfo 명령어를 통해 opencl 설정이 완료되었는지 확인하실 수 있습니다.
추가적으로 해당 방법의 경우 opencl 타겟 하드웨어 선택에 있어 cpu도 포함되어 있습니다.
===========================

'DLCompiler > OpenCL' 카테고리의 다른 글

그냥 이거로 하자...  (0) 2025.07.12
PoCL  (1) 2025.07.11
locate, updatedb  (0) 2025.07.10
OpenCL 헤더파일  (4) 2025.07.10
CUDA Tookit Docs  (1) 2025.07.09