Skip to content

Instantly share code, notes, and snippets.

@lseongjoo
Last active October 25, 2022 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lseongjoo/7bf064c6bac3fde01cfe3fa100787d33 to your computer and use it in GitHub Desktop.
Save lseongjoo/7bf064c6bac3fde01cfe3fa100787d33 to your computer and use it in GitHub Desktop.
데이터 과학 소프트웨어 라이브러리 성능 향상을 위한 설정

NumPy

BLAS(Basic Linear Algebra Subprograms)LAPACK(Linear Algebra Package)

https://numpy.org/install/#numpy-packages--accelerated-linear-algebra-libraries

소스 빌드

BLAS/LAPACK를 활용한 가속화 사용을 위해 NumPy 소스 코드르 직접 빌드할 때, 연결되는 라이브러리를 지정할 수 있습니다.

시스템의 기본 위치 (/usr, /usr/local 등)에 설치된 라이브러리를 자동으로 탐지해서 빌드되도록 하고자 하는 경우

$ pip install numpy --no-binary numpy

특정 위치의 라이브러리 경로를 제공하고자 하는 경우

$ LIB_DIR=/usr/local/lib/blis
$ INCLUDE_DIR=/usr/local/include/blis
$ pip install \
--global_option=build_ext --global_option="-L$LIB_DIR" --global_option="-I$INCLUDE_DIR" \
numpy --no-binary numpy

참조: NumPy 소스 빌드

동적 라이브러리 연결 변경

Unix 계열(Mac 또느 리눅스)에서는 update-alternative 명령으로 연결된 동적 라이브러리를 지정할 수 있습니다. 시스템에 설치된 BLAS 또는 LAPACK 라이브러리를 대상으로 지정할 수 있습니다.

conda

라이브러리 연결 설정(conda-forge)

conda install -c conda-forge numpy scipy

아래와 같이 특정 구현 연결 변경

conda install -c conda-forge "libblas=*=*blis"
conda install -c conda-forge "libblas=*=*mkl"
conda install -c conda-forge "libblas=*=*openblas"
conda install -c conda-forge "libblas=*=*accelerate"
conda install -c conda-forge "libblas=*=*netlib"

TensorFlow

GPU 가속 설정

Nvidia 그래픽 카드 및 드라이버가 설치되어 있어야 합니다.

Nvidia CUDA Toolkit 설치 문서

WSL

리포지토리 설정

$ sudo apt-key del 7fa2af80
$ wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.0-1_all.deb
$ sudo dpkg -i cuda-keyring_1.0-1_all.deb

CUDA 11.2, cuDNN 8.1 설치

$ sudo apt-get install cuda-11-2 libcudnn8=8.1.0.77-1+cuda11.2 libcudnn8-dev=8.1.0.77-1+cuda11.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment