2024년 3월 7일 목요일

How to set cuBLAS on Windows machine

 How to set cuBLAS on Windows machine


**warning**

- DO NOT install many version of cuda toolkit.

- check cuda toolkit compatible for your device

  : https://www.wikiwand.com/en/CUDA#/GPUs_supported\

- MUST CHECK which dev environment you use. 

  *pipenv on vscode, use vscode terminal.

  *on anaconda, use anaconda terminal


**install**

1. install cuda toolkit => https://developer.nvidia.com/cuda-toolkit-archive

2. install visual studio with these options below

 - C++ core features

 - MSVC vxxx - VS 2022 C++ x64/x86 build tool

 - C++ CMake tools for Windows.

 - Windows 10/11 SDK.


**cuda version check**

 - nvcc --version 

   or 

 - nvidia-smi


**run old command shell as administrator, not in powershell**


1. clone llama-cpp-python

  git clone --recursive -j8 https://github.com/abetlen/llama-cpp-python.git


2. clone llama.cpp

  git clone https://github.com/ggerganov/llama.cpp


3. move "llama.cpp" folder into "llama-cpp-python/vendor/"


4. cd llama-cpp-python


5. run commands below

  mkdir build

  cd build

  cmake .. -DLLAMA_CUBLAS=ON

  cmake --build . --config Release


6. set environment values below

  set FORCE_CMAKE=1

  set CMAKE_ARGS=-DLLAMA_CUBLAS=ON


  * you can check the value you set with "echo %FORCE_CMAKE%"


7. run below command in llama-cpp-python folder

  python -m pip install -e . --force-reinstall --prefer-binary --no-cache-dir --extra-index-url=https://jllllll.github.io/llama-cpp-python-cuBLAS-wheels/AVX2/cu118


  ** check your cudatoolkit version and put it at the end of the command above.

 ex) cu120 or cu12.2 etc

2023년 10월 18일 수요일

How to download Datasets on google colab.

아주 잘 설명된 웹사이트

** 위 내용중 Competition이 아니라 Datasets 사이트에 접속하면 우측에 "..." 버튼 클릭 후 

Copy API command를 클릭하면 shell command가 버퍼에 복사됨.


** 자세히 읽어보면 kaggle.json 파일을 업로드하면 /root/ 디렉토리로 업로드 되는게 아니고 그 아래 명령어를 실행해야지만 해당 위치로 복사한다는 의미이니 일단 command를 무조건 따라 입력하여 실행하도록한다.

2023년 8월 6일 일요일

How to debug python source code with streamlit library in vscode

 in launch.json

"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"module": "streamlit",
"console": "integratedTerminal",
"justMyCode": true,
"cwd": "${fileDirname}",
"env": {"PYTHONPATH": "${workspaceFolder}${pathSeparator}${env:PYTHONPATH}"},
"args": [
"run",
"${file}",
"--server.fileWatcherType",
"none"
]
},
]

2023년 7월 31일 월요일

우분투 18.04 LTS 에서 기본 파이썬 버전 설정

우분투 기본 파이썬 버전은 3.6.1이다.

버전을 올리려면 apt로는 아무리해도 안된다. 꾸역꾸역 하다가 OS 망가져서 우분투 새로 설치함.

소스를 받아서 빌드를 하라고하는데 자칫하면 우분투 새로설치해야할지도 몰라 안함.


*** 아래에 따라 파이썬 버전 변경하면 터미널이 안열리게 됨.

sudo update-alternatives --config python3 # ==> 실행해서 원래버전으로 변경하면 실행됨



그냥 아나콘다가 설치해주는 상위버전(3.11)이 있으니 기본 파이썬 실행 위치를 설정하면 된다.


# anaconda 가 설치 되어 있어야한다.

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1

sudo update-alternatives --install /usr/bin/python3 python3 /home/hanson/anaconda3/bin/python3.11 2


# 아래 명령어 실행 하면 기본 파이썬 버전을 선택할 수 있다.

sudo update-alternatives --config python3


# 버전확인

python3 -V

2022년 9월 25일 일요일

Setting Korean fonts for Matplotlib on Ubuntu 18.04-LTS

** 참고사이트 : https://hooni-playground.com/961/

** 참고도서 : 파이썬을 활용한 금융공학 레시피

# 폰트설치

$ sudo apt-get install fonts-nanum*


# 캐시삭제

$ fc-cache -fv


# 주피터 노트북에서 확인

>>> import matplotlib

>>> matplotlib.__file__

'/home/xxxxxx/anaconda3/envs/quant/lib/python3.9/site-packages/matplotlib/pyplot.py'

# 위 '/site-pakages/' 이전 절대경로를 복사해서 아래 폰트 설치될 경로에 맞게 수정해서 명령어 실행.

$ cp /usr/share/fonts/truetype/nanum/Nanum* /home/xxxxxx/anaconda3/envs/quant/lib/python3.9/site-packages/matplotlib/mpl-data/fonts/ttf/


# Matplotlib 폰트 캐시 삭제

$ rm -rf ~/.cache/matplotlib/*


# 주피터 노트북 및 아나콘다 종료 후 재실행해야 설치한 폰트 목록이 출력됨.

>>> from matplotlib import font_manager

>>> set(sorted([f.name for f in font_manager.fontManager.ttflist]))


# Matplotlib에 폰트 설정.

>>> plt.rcParams['font.family'] = 'NanumGothicCoding'

>>> plt.rcParams['font.size'] = 12

>>> plt.rcParams['axes.unicode_minus'] = False