私的AI研究会 > ProjectEnv3
AI開発プロジェクト実行に必要な環境を新しく作成する手順(最新版)
『PyTorch ではじめる AI開発』以降のページを実行するために新しく環境を作成する
同時に「NVIDIA cuda GPU」を使用できる環境構築をする
HP ENVY Desktop TE02-1097jp
(base) PS > conda update -n base -c defaults conda Collecting package metadata (current_repodata.json): done Solving environment: done : Proceed ([y]/n)? y ← 'y' を入力する : Executing transaction: done Retrieving notices: ...working... done
(base) PS > echo $env:PYTHONPATH C:\anaconda_win\workspace_py37\mylib;C:\anaconda_win\workspace\lib
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\<User>\anaconda3' "・次のように変更 <User> = ユーザー名 C: = anaconda_winを配置したドライブ
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\<User>\anaconda3' ; Set-Location 'c:\anaconda_win' "
名称 | Python | PyTorch | プロジェクト名称 | 主に使用するプロジェクトフォルダ |
base | 3.11.5 | - | - | - |
py311 | 3.11.5 | 2.1.2+cu121 | - | /work |
py37 | 3.7.16 | 1.13.1 | PyTorch ではじめる AI開発 | /workspace_py37 |
py37x | 3.7.11 | 1.10.1 | 文字認識「OCR」 | /workspace_py37 |
py37y | 3.7.11 | 1.10.1 | 顔認証「Face recognition」 | /workspace_py37 |
py38 | 3.8.18 | 2.1.2 | 画像生成「Stable-diffusion」 | /workspace_py38 |
py38a | 3.8.18 | 2.1.2 | 物体認識「YOLO V7」 | /work |
py38b | 3.8.18 | 2.1.2+cu121 | 物体認識「YOLO V7」 | /work |
py38_gan | 3.8.18 | 2.1.2 | GAN(敵対的生成ネットワーク)」 | /work |
py_learn | 3.11.7 | 2.2.0+cu121 | PyTorch ではじめる AI開発(復習) | /workspace_pylearn |
python -V python -c 'import torch;print(torch.__version__)' python /anaconda_win/workspace_py37/cuda_test.py※ cuda 利用可能な環境では PyTorch インストール時に指定がない場合、標準で cuda 対応版がインストールされる
(***) PS > conda info -e
(***) PS > python -V
(base) PS > conda activate py38 (py38)
(py38) PS > cd /anaconda_win/work/
(py38) PS > conda deactivate (base)
(base) PS > conda create -n py37 python=3.7
(base) PS > conda activate py37 (py37) PS >
(py37) PS > conda info -e # conda environments: # base C:\Users\USER\anaconda3 py37 * C:\Users\USER\anaconda3\envs\py37※ USER: ユーザー名, *: 現在アクティブな仮想環境
(py37) PS > pip install torch torchvision torchaudio
(py37) PS > conda install opencv
(py37) PS > conda install pandas
(py37) PS > conda install tqdm
(py37) PS > conda install matplotlib
(py37) PS > conda install PyYAML
(py37) PS > pip install scikit-learn
(py37) PS > pip install pycocotools
(py37) PS > pip install facenet-pytorch
(py37) PS > python -c "import torch"
(py37) PS > python -c 'import torch;print(torch.zeros(1).cuda())' Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\izuts\anaconda3\envs\py37\lib\site-packages\torch\cuda\__init__.py", line 221, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled※ 今回ドライバをインストールしていないのでエラーとなる
(py37) PS > python -c 'import tkinter'
(py37) PS > ffmpeg -h
(py37) PS > cd /anaconda_win/workspace_py37/sample/chapt01 (py37) PS > python3 chapt01_1.py
(py37) PS > python --version Python 3.7.16
(py37) PS > conda info
(py37) PS > python -c "import numpy; print( numpy.__version__ )" 1.21.5
/anaconda_win ├─Images ← アプリケーションで利用する画像ファイル ├─model ← OpenVINOアプリケーションで利用する学習済みモデル │ ├─intel │ │ └─FP32 │ └─public │ └─FP32 ├─Videos ← アプリケーションで利用する動画ファイル ├─workspace ← OpenVINO を移用したアプリケーション・プロジェクト │ └─_apps ← anaconda (Windows/Linux) 環境に対応したアプリケーション ※ └─workspace_py37 ← anaconda 環境下のアプリケーション・プロジェクト ├─exercise ← GUI 環境構築のテスト ├─pyocr ← OCR のテストアプリケーション ※ ├─tryocr ← OCR アプリケーション作成プロジェクト(旧藩) ※ │ ├─formocr ← OCR アプリケーション作成プロジェクト ※ └─environment_py37x.yaml ← 仮想環境設定ファイル ※ anaconda (Windows/Linux) 環境に対応したプロジェクト
(base) PS > cd /anaconda_win/workspace_py37 ← 「environment_py37x.yaml」ファイルのある場所へ (base) PS > conda env create -f environment_py37x.yaml
(base) PS > conda activate py37x (py37x) PS >
(py37x) PS > conda info -e # conda environments: # base C:\Users\USER\anaconda3 py311 C:\Users\USER\anaconda3\envs\py311 py37 C:\Users\USER\anaconda3\envs\py37 py37x * C:\Users\USER\anaconda3\envs\py37x py38 C:\Users\USER\anaconda3\envs\py38
(py37x) PS > python -c "import torch" (py37x) PS > python -c "import tkinter" (py37x) PS > python -c "from openvino.inference_engine import IECore"
(base) PS > echo $env:Path C:\Users\USER\anaconda3;.................................;C:\Program Files\Tesseract-OCR;. (base) PS > echo $env:TESSDATA_PREFIX C:\Program Files\Tesseract-OCR\tessdata (base) PS > echo $env:PYTHONPATH C:\anaconda_win\workspace_py37\mylib
参照ページ → 「実用的な AI開発へ - 文字認識エンジン「Tesseract」
ソースコードの場所 (すべて Linux/Windows 環境に対応)(py37x) PS > cd /anaconda_win/workspace_py37/pyocr
(py37x) PS > python initialization.py Will use tool 'Tesseract (sh)' Available languages: eng, jpn, jpn_vert, osd, script/Japanese, script/Japanese_vert Will use lang 'eng'
(py37x) PS > python ocrtest.py
(py37x) PS > python ocrtest_cam.py
(py37x) PS > python ocrtest1.py
(py37x) PS > python ocrtest2.py
(py37x) PS > python ocrtest3.py
(py37x) PS > python ocrtest4.py
(py37x) PS > python tryocr.py
参照ページ → 実用的な AI開発へ - OCR アプリケーションを作る
ソースコードの場所 (すべて Linux/Windows 環境に対応)(py37x) PS > cd /anaconda_win/workspace_py37/tryocr
(py37x) PS > python tryocr_step1.py
(py37x) PS > python tryocr_step2.py
(py37x) PS > python tryocr_step3.py
(py37x) PS > python mylib_yaml.py
(py37x) PS > python tryocr_step4.py
(py37x) PS > python tryocr_step5.py
(py37x) PS > python tryocr_step6.py
参照ページ → 帳票OCRプログラム「FormOCR」:サンプルデータを使って練習
ソースコードの場所 (すべて Linux/Windows 環境に対応)(py37x) PS > cd /anaconda_win/workspace_py37/formocr
(py37x) PS > python prepros.py -r 0
(py37x) PS > python formocr.py
(py37x) PS > python formocr_edit.py
(py37x) PS > cd /anaconda_win/workspace/_apps
(py37x) PS > python emotion2.py (py37x) PS > python age_gender2.py (py37x) PS > python object_detect_yolo3_2.py (py37x) PS > python person-tracking2.py (py37x) PS > python face-tracking2.py
(py37x) PS > python sentiment_analysis2.py (py37x) PS > python image_classification.py (py37x) PS > python virtual_fitting.py (py37x) PS > python face_mask.py
(base) PS > cd /anaconda_win/workspace_py37 ← 「win_environment_py37y.yaml」ファイルのある場所へ (base) PS > conda env create -f win_environment_py37y.yaml
(base) PS > conda activate py37y (py37y) PS >
(py37y) PS > pip install protobuf==3.20 (py37y) PS > pip install onnxruntime
(py37y) PS > cd /anaconda_win/workspace_py37/inface (py37y) PS > pip install insightface・「opencv-python-headless」がインストールされるので削除
(py37y) PS > pip uninstall opencv-python-headless・ InsightFace のテスト
(py37y) PS > cd /anaconda_win/workspace_py37/inface (py37y) PS > python face_test.py・ InsightFace でカメラ入力をテスト
(py37y) PS > python face_test1.py
(py37y) PS > conda install -c conda-forge dlib (py37y) PS > conda install -c conda-forge face_recognition・「face recognition」パッケージのテスト
(py37y) PS > cd /anaconda_win/workspace_py37/inface (py37y) PS > python face_rec_test.py (py37y) PS > python face_rec_test1.py・カメラによるリアルタイム顔判定
(py37y) PS > cd /anaconda_win/workspace_py37/inface (py37y) PS > python face_rec_test2.py
(py37y) PS > cd /aconda_win/workspace_py37/face_rec (py37y) PS > python face_rec1.py Starting.. - Program title : Face recognition (step1) Ver 0.02 : FPS average: 14.20 Finished.
(py37y) PS > python face_rec2.py Starting.. - Program title : Face recognition (step2) Ver 0.02 : FPS average: 20.20 Finished.
(py37y) PS > cd /anaconda_win/workspace_py37/face_rec_try/ (py37y) PS > python find_faces_in_picture.py
(py37y) PS > python find_faces_in_picture_cnn.py
(py37y) PS > python face_recognition_knn.py
(py37y) PS > python face_recognition_svm.py
(py37y) PS > cd /anaconda_win/workspace_py37/face_rec/ (py37y) PS > python face_rec3.py
(py37y) PS > python python face_rec_still.py --tol 0.5.py
(py37y) PS > conda install -c conda-forge readchar (py37y) PS > conda install -c conda-forge pyserial
(py37y) PS > python door_ctrl.py /dev/ttyUSB0 'COM3' port ready. b'd' b'o' b'c' b'q' Program Finished.
(py37y) PS > python face_rec3d.py -p /dev/ttyUSB0 Starting.. - Program title : Face recognition (step3) Ver 0.02 : - UART port name : COM3 '/dev/ttyUSB0' port ready. FPS average: 26.70 Finished.
(py37y) PS > cd /anaconda_win/workspace_py37/jtalk/ (py37y) PS > python jtalkw.py
(py37y) PS > cd /anaconda_win/workspace_py37/jtalk/ (py37y) PS > python mail.py
(py37y) PS > cd /anaconda_win/workspace_py37/face_rec (py37y) PS > python face_rec_yaml.py
(py37y) PS > python rec_result.py
(py37y) PS > python face_rec4.py Starting.. - Program title : Face recognition (step4) Ver 0.04 : subject : '2024/01/12 10:37:40 : 受付' message : '井筒 政弘 様 来社です hostname : ubuntu-HP-ENVY from : aipromotion999@gmail.com to : izutsum-sp@docomo.ne.jp' FPS average: 25.70 Finished.
(py37y) PS > cd /anaconda_win/workspace_py37/reception (py37y) PS > python reception.py Starting.. - Program title : Reception System Ver 0.01 : 'COM3' port ready. QWindowsWindow::setGeometry: Unable to set geometry 98x69+21+31 (frame: 114x108+13+0) on QWidgetWindow/"Reception System Ver 0.01 (hit 'q' or 'esc' key to exit)Window" on "\\.\DISPLAY1". Resulting geometry: 120x69+21+31 (frame: 136x108+13+0) margins: 8, 31, 8, 8 minimum size: 98x69 maximum size: 98x69 MINMAXINFO maxSize=0,0 maxpos=0,0 mintrack=114,108 maxtrack=114,108) subject : '2023/12/20 15:01:50 : 受付' message : '井筒 政弘 様 来社です hostname : HP-ENVY_TE02 from : aipromotion999@gmail.com to : izutsum-sp@docomo.ne.jp' [ WARN:0] global D:\bld\libopencv_1632857438825\work\modules\videoio\src\cap_msmf.cpp (438) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback FPS average: 25.60 Finished.
(py37y) PS > cd /anaconda_win/workspace_py37/openvino/
(py37y) PS > python emotion3.py (py37y) PS > python age_gender3.py (py37y) PS > python object_detect_yolo3_3.py (py37y) PS > python object_detect_yolo5.py (py37y) PS > python person-tracking3.py (py37y) PS > python face-tracking3.py
(py37y) PS > python sentiment_analysis3.py (py37y) PS > python image_classification3.py (py37y) PS > python virtual_fitting3.py (py37y) PS > python face_mask3.py
(base) PS > conda create -n py38 python=3.8
(base) PS > conda info -e # conda environments: # base * C:\Users\USER\anaconda3 py311 C:\Users\USER\anaconda3\envs\py311 py37 C:\Users\USER\anaconda3\envs\py37 py38 C:\Users\USER\anaconda3\envs\py38 (base) PS > conda activate py38 (py38) PS > ← (py38) に切り替わっていることを確認する
c:/anaconda_win ├─workspace_py37 │ ├─mylib ← python 共有ライブラリ (パスが通っていること) │ └─openvino └─workspace_py38 ← anaconda 環境下のアプリケーション・プロジェクト ├─googletrans └─stable_diffusion
(py38) PS > cd /anaconda_win/workspace_py38\stable_diffusion (py38) PS > python -m pip install --upgrade pip (py38) PS > pip install openvino==2022.1.0 (py38) PS > pip install -r requirements.txt
(py38) PS > cd /anaconda_win/workspace_py38\stable_diffusion (py38) PS > python demo.py --prompt "Street-art painting of Tom Cruise in style of Gogh, photorealism" 32it [01:11, 2.24s/it]↑ -- 1回あたりの演算速度(秒)
Downloading: 100%|██████████████████████████████| 905/905 [00:00<00:00, 668kB/s] Downloading: 100%|████████████████████████████| 939k/939k [00:01<00:00, 867kB/s] Downloading: 100%|████████████████████████████| 512k/512k [00:00<00:00, 626kB/s] Downloading: 100%|██████████████████████████████| 389/389 [00:00<00:00, 402kB/s] Downloading: 100%|█████████████████████████| 2.12M/2.12M [00:01<00:00, 1.42MB/s] Downloading: 100%|████████████████████████████| 464k/464k [00:00<00:00, 548kB/s] Downloading: 100%|███████████████████████████| 492M/492M [00:11<00:00, 42.2MB/s] Downloading: 100%|█████████████████████████| 3.02M/3.02M [00:01<00:00, 1.77MB/s] Downloading: 100%|█████████████████████████| 3.44G/3.44G [02:10<00:00, 26.4MB/s] Downloading: 100%|████████████████████████████| 329k/329k [00:00<00:00, 473kB/s] Downloading: 100%|███████████████████████████| 198M/198M [00:09<00:00, 20.7MB/s] Downloading: 100%|████████████████████████████| 252k/252k [00:00<00:00, 448kB/s] Downloading: 100%|███████████████████████████| 137M/137M [00:05<00:00, 23.3MB/s]※ Windows で管理権限がないとエラーになるとき → ここを参照
(py38) PS > pip install googletrans==4.0.0-rc1
(py38) PS > cd /anaconda_win/workspace_py38/googletrans (py38) PS > python test3.py
(py38a) PS > cd /anaconda_win/workspace_py38/stable_diffusion/ (py38a) PS > python stable_diffusion2.py Starting.. - Program title : Stable Diffusion2 OpenVINO™ Ver 0.03 : Prompt: Beautiful green forest where light shines (和訳): 光が輝く美しい緑の森 ** start 0 ** 799752338 32it [01:11, 2.24s/it] -Output-: result/output_0799752338.png ** end ** 00:01:35 Finished.
(py38) PS > python stable_diffusion_make2.py
プロジェクト・ホーム(c:/anaconda_win または ~/) ├─Images ← 画像データ ├─model ← 学習済みモデル ├─Videos ← 動画データ │ : ├─work ← 今回使用するプロジェクト・ディレクトリ │ ├─openvino │ └─yolov7 ├─workspace_py37 │ └─mylib ← python 共有ライブラリ (パスが通っていること) └─workspace_py38 ← anaconda 環境下のアプリケーション・プロジェクト ├─ : └─stable_diffusion
(base) PS > conda create -n py38a python=3.8
(base) PS > $ conda activate py38a (py38a) PS > ← (py38a) に切り替わっていることを確認する (py38a) PS > conda info -e # conda environments: # base C:\Users\USER\anaconda3 py311 C:\Users\USER\anaconda3\envs\py311 : py38 C:\Users\USER\anaconda3\envs\py38 py38a * C:\Users\USER\anaconda3\envs\py38a
# Stable Diffusion & YOLOv7_OpenVINO openvino==2022.1.0 numpy==1.19.5 opencv-python==4.5.5.64 transformers==4.16.2 diffusers==0.2.4 tqdm==4.64.0 huggingface_hub==0.9.0 scipy==1.9.0 streamlit==1.12.0 watchdog==2.1.9 ftfy==6.1.1 PyMuPDF torchvision matplotlib seaborn onnx googletrans==4.0.0-rc1
(py38a) PS > cd /anaconda_win/work (py38a) PS > pip install -r requirements.txt
(py38a) PS > cd /anaconda_win/work/yolov7 (py38a) PS > python object_detect_yolo7.py
(py38a) PS > cd /anaconda_win/work/openvino/ (py38a) PS > python object_detect_yolo5.py (py38a) PS > python object_detect_yolo3.py
(py38a) PS > cd /anaconda_win/work/yolov7 (py38a) PS > python object_detect_yolo7.py -m mask_best.onnx -l mask.names_jp -i ../../Images/mask.jpg -o out_mask.jpg
(py38a) PS > pip install labelImg (py38a) PS > cd /anaconda_win/work/labelImg/janken/ (py38a) PS > labelImg par predefined_classes.txt par
(py38a) PS > cd /anaconda_win/work/yolov7-main (py38a) PS > python detect2.py --weights runs/train/yolov7x_custom2_60/weights/best.pt --conf 0.25 --img-size 640 --source ../../Images/janken2.jpg --view-img
(py38a) PS > cd /anaconda_win/work/yolov7 (py38a) PS > python object_detect_yolo7.py -m ../yolov7-main/runs/train/yolov7x_custom2_60/weights/best.onnx -l janken.names_jp -i cam (py38a) PS > python object_detect_yolo7.py -m ../yolov7-main/runs/train/yolov7x_custom2_60/weights/best.onnx -l janken.names_jp -i ../../Images/janken2.jpg
(py38a) PS > cd /anaconda_win/work/yolov7 (py38a) PS > python object_detect_yolo7.py -m ../yolov7-main/runs/train/yolov7x_custom4_60/weights/best.onnx -l janken.names_jp -i ../../Images/janken3.jpg -o janken3_custom4_60.jpg
(base) PS > conda create -n py38b python=3.8
(base) PS > $ conda activate py38b (py38b) PS > ← (py38b) に切り替わっていることを確認する (py38b) PS > conda info -e # conda environments: # base C:\Users\USER\anaconda3 py311 C:\Users\USER\anaconda3\envs\py311 : py38b * C:\Users\USER\anaconda3\envs\py38b
# Stable Diffusion & YOLOv7_OpenVINO openvino==2022.1.0 numpy==1.19.5 opencv-python==4.5.5.64 transformers==4.16.2 diffusers==0.2.4 tqdm==4.64.0 huggingface_hub==0.9.0 scipy==1.9.0 streamlit==1.12.0 watchdog==2.1.9 ftfy==6.1.1 PyMuPDF torchvision matplotlib seaborn onnx googletrans==4.0.0-rc1
(py38b) PS > cd /anaconda_win/work (py38b) PS > pip install -r requirements.txt
(py38b) PS C:\anaconda_win\work\yolov7-main> python Python 3.8.18 (default, Sep 11 2023, 13:39:12) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import torch >>> print(torch.__version__) 2.1.2+cpu >>> import torchvision >>> print(torchvision.__version__) 0.16.2+cpu >>> quit()
(py38b) PS > pip uninstall torch torchvision torchaudio
(py38b) PS C:\anaconda_win\work\labelImg\janken> nvidia-smi Thu Dec 21 05:03:56 2023 +---------------------------------------------------------------------------------------+ | NVIDIA-SMI 546.33 Driver Version: 546.33 CUDA Version: 12.3 | |-----------------------------------------+----------------------+----------------------+ | GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+======================+======================| | 0 NVIDIA GeForce RTX 4070 Ti WDDM | 00000000:01:00.0 On | N/A | | 31% 28C P8 6W / 285W | 743MiB / 12282MiB | 0% Default | | | | N/A | +-----------------------------------------+----------------------+----------------------+ +---------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=======================================================================================| | 0 N/A N/A 5764 C+G ...2txyewy\StartMenuExperienceHost.exe N/A | | 0 N/A N/A 8136 C+G ...CBS_cw5n1h2txyewy\TextInputHost.exe N/A | | 0 N/A N/A 9764 C+G ...nt.CBS_cw5n1h2txyewy\SearchHost.exe N/A | | 0 N/A N/A 10364 C+G ....0_x64__8wekyb3d8bbwe\HxOutlook.exe N/A | | 0 N/A N/A 11044 C+G ...5n1h2txyewy\ShellExperienceHost.exe N/A | | 0 N/A N/A 12760 C+G ...__8wekyb3d8bbwe\WindowsTerminal.exe N/A | | 0 N/A N/A 14264 C+G ...ke6\Win32\HPEnhancedLighting.Bg.exe N/A | | 0 N/A N/A 14716 C+G ...on\120.0.2210.77\msedgewebview2.exe N/A | | 0 N/A N/A 15020 C+G ...t.LockApp_cw5n1h2txyewy\LockApp.exe N/A | | 0 N/A N/A 15164 C+G ...siveControlPanel\SystemSettings.exe N/A | | 0 N/A N/A 16120 C+G ...GeForce Experience\NVIDIA Share.exe N/A | | 0 N/A N/A 16192 C+G ...tility\HPSystemEventUtilityHost.exe N/A | | 0 N/A N/A 16892 C+G ...App\OmenCommandCenterBackground.exe N/A | | 0 N/A N/A 17376 C+G ...crosoft\Edge\Application\msedge.exe N/A | | 0 N/A N/A 18404 C+G ...cal\Microsoft\OneDrive\OneDrive.exe N/A | | 0 N/A N/A 18668 C+G ...on\120.0.2210.77\msedgewebview2.exe N/A | | 0 N/A N/A 20004 C+G ...00.0_x64__v10z8vjag6ke6\HP.myHP.exe N/A | | 0 N/A N/A 20412 C+G C:\Windows\explorer.exe N/A | | 0 N/A N/A 20848 C+G ...10z8vjag6ke6\HpSystemManagement.exe N/A | +---------------------------------------------------------------------------------------+
(py38b) PS > pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
(py38b) PS > conda list # packages in environment at C:\Users\USER\anaconda3\envs\py38b: # # Name Version Build Channel : torch 2.1.2+cu121 pypi_0 pypi torchaudio 2.1.2+cu121 pypi_0 pypi torchvision 0.16.2+cu121 pypi_0 pypi :
(py38b) PS > python Python 3.8.18 (default, Sep 11 2023, 13:39:12) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import torch >>> print(torch.__version__) 2.1.2+cu121 >>> import torchvision >>> print(torchvision.__version__) 0.16.2+cu121 >>> quit()
(py38b) PS > cd /anaconda_win/workspace_py37 (py38b) PS > python cuda_test.py 2.1.2+cu121 cuda, True compute_89 find gpu devices, 1 cuda:0, NVIDIA GeForce RTX 4070 Ti end
(py38b) PS > pip install tensorboard
(py38b) PS > git config --global user.name izuts (py38b) PS > git config --global user.email izutsum@venus.dti.ne.jp (py38b) PS > ssh-keygen Generating public/private rsa key pair. : デフォルトで問題ないので何も入力せずにEnterを押す
(py38b) PS > git --version git version 2.43.0.windows.1
(py38b) PS > cd /anaconda_win/work/yolov7-main (py38b) PS > python train.py --workers 8 --batch-size 16 --data janken_dataset.yaml --cfg cfg/training/yolov7x.yaml --weights 'yolov7x.pt' --name yolov7x_custom2 --hyp data/hyp.scratch.p5.yaml --epochs 300 --device 0
(py38b) PS > cd /anaconda_win/work/yolov7-main (py38b) PS > python train.py --workers 16 --batch-size 16 --data janken_dataset.yaml --cfg cfg/training/yolov7x.yaml --weights 'yolov7x.pt' --name yolov7x_custom2 --hyp data/hyp.scratch.p5.yaml --epochs 300 --device 0
: Epoch gpu_mem box obj cls total labels img_size 1/299 9.13G 0.05278 0.01643 0.02072 0.08993 24 640: 100%|█| 60/60 [00:12<00:00, 4.97it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100%|█| 8/8 [00:00<00:00, all 120 120 0.251 0.283 0.197 0.0455 Epoch gpu_mem box obj cls total labels img_size 2/299 10.7G 0.04662 0.0146 0.0188 0.08003 28 640: 100%|█| 60/60 [00:11<00:00, 5.01it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100%|█| 8/8 [00:00<00:00, all 120 120 0.229 0.533 0.289 0.0803 :・Tesla T4 16GB(51.5s / 1 Epoch)
: Epoch gpu_mem box obj cls total labels img_size 1/299 9.48G 0.05013 0.01651 0.01977 0.08641 27 640: 100% 60/60 [00:53<00:00, 1.13it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:03<00:00, 2.29it/s] all 120 120 0.168 0.292 0.149 0.0273 Epoch gpu_mem box obj cls total labels img_size 2/299 11G 0.047 0.01419 0.01878 0.07998 20 640: 100% 60/60 [00:50<00:00, 1.19it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:03<00:00, 2.27it/s] all 120 120 0.182 0.4 0.217 0.0691 :
(base) PS > conda create -n py38_gan python=3.8
(base) PS > $ conda activate py38_gan (py38_gan) PS > ← (py38a) に切り替わっていることを確認する (py38_gan) PS > conda info -e # conda environments: # base C:\Users\USER\anaconda3 py311 C:\Users\USER\anaconda3\envs\py311 : py38_gan * C:\Users\USER\anaconda3\envs\py38_gan
(py38_gan) PS > cd /anaconda_win/work/ $ git clone https://github.com/clovaai/stargan-v2.git
(py38_gan) PS > pip install -r requirements.txt
(py38_gan) PS > pip install munch scikit-image ffmpeg
checkpoint_patch.py → checkpoint.py solver_patch.py → solver.py wing_patch.py → wing.py
(py38_gan) PS > cd /anaconda_win/work/stargan-v2/ (py38_gan) PS > python main.py --mode sample --num_domains 2 --resume_iter 100000 --w_hpf 1 --checkpoint_dir expr/checkpoints/celeba_hq --result_dir expr/results/celeba_hq --src_dir assets/representative/celeba_hq/src_0 --ref_dir assets/representative/celeba_hq/ref_0 (py38_gan) PS > python main2.py --mode sample --num_domains 2 --resume_iter 100000 --w_hpf 1 --checkpoint_dir expr/checkpoints/celeba_hq --result_dir expr/results/celeba_hq --src_dir assets/representative/celeba_hq/src_0 --ref_dir assets/representative/celeba_hq/ref_0・カスタム画像を変換する
(py38_gan) PS > python main.py --mode align --inp_dir assets/representative/custom_1/male --out_dir assets/representative/celeleba_hq --src_dir assets/representative/celeba_hq/src_0 --ref_dir assets/representative/celeba_hq/ref_0・カスタム画像を使って実行する
(py38_gan) PS > python main2.py --mode sample --num_domains 2 --resume_iter 100000 --w_hpf 1 --checkpoint_dir expr/checkpoints/celeba_hq --result_dir expr/results/celeba_hq --src_dir assets/representative/celeba_hq/src --ref_dir assets/representative/celeba_hq/ref_1 (py38_gan) PS > python main2.py --mode sample --num_domains 2 --resume_iter 100000 --w_hpf 1 --checkpoint_dir expr/checkpoints/celeba_hq --result_dir expr/results/celeba_hq --src_dir assets/representative/celeba_hq/src_3 --ref_dir assets/representative/celeba_hq/ref_1 (py38_gan) PS > python main2.py --mode sample --num_domains 2 --resume_iter 100000 --w_hpf 1 --checkpoint_dir expr/checkpoints/celeba_hq --result_dir expr/results/celeba_hq --src_dir assets/representative/celeba_hq/src --ref_dir assets/representative/celeba_hq/ref_0 (py38_gan) PS > python main2.py --mode sample --num_domains 3 --resume_iter 100000 --w_hpf 0 --checkpoint_dir expr/checkpoints/afhq --result_dir expr/results/afhq --src_dir assets/representative/afhq/src_0 --ref_dir assets/representative/afhq/ref_0
(py38_gan) PS > cd /anaconda_win/work/ (py38_gan) PS > git clone https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix.git (py38_gan) PS > pip install dominate visdom
(py38_gan) PS > cd /anaconda_win/work/pytorch-CycleGAN-and-pix2pix/ (py38_gan) PS > python test.py --dataroot datasets/images --name style_ukiyoe_pretrained --model test --no_dropout --preprocess scale_width --load_size 1024 --gpu_ids -1 (py38_gan) PS > python test.py --dataroot datasets/images --name style_monet_pretrained --model test --no_dropout --preprocess scale_width --load_size 1024 --gpu_ids -1 (py38_gan) PS > python test.py --dataroot datasets/images --name style_cezanne_pretrained --model test --no_dropout --preprocess scale_width --load_size 1024 --gpu_ids -1 (py38_gan) PS > python test.py --dataroot datasets/images --name style_vangogh_pretrained --model test --no_dropout --preprocess scale_width --load_size 1024 --gpu_ids -1
(py38_gan) PS > pip install yt-dlp・ YouTube 動画のURL を右クリックでコピーし、下記コマンドでダウンロードする
(py38_gan) PS > python ytb_down.py 'YouTube 動画のURLをペースト'
アーキテクチャ (読み方) | プロセスルール | 販売開始 | 採用シリーズ |
Kepler (ケプラー) | 28nm | 2012年 | GeForce GTX/GT 600シリーズ |
2012年 | GeForce GTX/GT 700シリーズ | ||
2013年 | GeForce GTX TITANシリーズ | ||
Maxwell (マクスウェル) | 28nm | 2014年 | GeForce GTX 700シリーズ |
2015年 | GeForce GTX 900シリーズ | ||
Pascal (パスカル) | 16nm/14nm | 2016年 | GeForce GTX 10シリーズ |
Turing (チューリング) | 12nm | 2018年 | GeForce RTX 20シリーズ |
2019年 | GeForce GTX 16シリーズ | ||
Ampere (アンペア) | 8nm | 2020年 | GeForce RTX 30シリーズ |
Ada Lovelace (エイダ・ラブレス) | 5nm | 2022年 | GeForce RTX 40シリーズ |
(base) PS > nvidia-smi Fri Dec 15 07:51:42 2023 +---------------------------------------------------------------------------------------+ | NVIDIA-SMI 546.33 Driver Version: 546.33 CUDA Version: 12.3 | |-----------------------------------------+----------------------+----------------------+ | GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+======================+======================| | 0 NVIDIA GeForce RTX 4070 Ti WDDM | 00000000:01:00.0 On | N/A | | 31% 28C P8 3W / 285W | 429MiB / 12282MiB | 1% Default | | | | N/A | +-----------------------------------------+----------------------+----------------------+ +---------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=======================================================================================| | 0 N/A N/A 3044 C+G ...5n1h2txyewy\ShellExperienceHost.exe N/A | | 0 N/A N/A 6432 C+G ...CBS_cw5n1h2txyewy\TextInputHost.exe N/A | | 0 N/A N/A 10200 C+G ...2txyewy\StartMenuExperienceHost.exe N/A | | 0 N/A N/A 10772 C+G ...__8wekyb3d8bbwe\WindowsTerminal.exe N/A | | 0 N/A N/A 11012 C+G ....0_x64__8wekyb3d8bbwe\HxOutlook.exe N/A | | 0 N/A N/A 11328 C+G ...on\120.0.2210.61\msedgewebview2.exe N/A | | 0 N/A N/A 13636 C+G ...ke6\Win32\HPEnhancedLighting.Bg.exe N/A | | 0 N/A N/A 14792 C+G ...GeForce Experience\NVIDIA Share.exe N/A | | 0 N/A N/A 15028 C+G ...tility\HPSystemEventUtilityHost.exe N/A | | 0 N/A N/A 15652 C+G ...cal\Microsoft\OneDrive\OneDrive.exe N/A | | 0 N/A N/A 16368 C+G C:\Windows\explorer.exe N/A | | 0 N/A N/A 18508 C ...vVirtualCamera\NVIDIA Broadcast.exe N/A | | 0 N/A N/A 20304 C+G ...App\OmenCommandCenterBackground.exe N/A | | 0 N/A N/A 21020 C+G ...siveControlPanel\SystemSettings.exe N/A | | 0 N/A N/A 23272 C+G C:\Windows\explorer.exe N/A | | 0 N/A N/A 23332 C+G ...5n1h2txyewy\AccountsControlHost.exe N/A | | 0 N/A N/A 24544 C+G ...0_x64__8wekyb3d8bbwe\HxAccounts.exe N/A | | 0 N/A N/A 24584 C+G ...nt.CBS_cw5n1h2txyewy\SearchHost.exe N/A | +---------------------------------------------------------------------------------------+Graphic board: NVIDIA GeForce RTX 4070 Ti
(base) PS > nvcc -V nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2023 NVIDIA Corporation Built on Fri_Nov__3_17:51:05_Pacific_Daylight_Time_2023 Cuda compilation tools, release 12.3, V12.3.103 Build cuda_12.3.r12.3/compiler.33492891_0
(base) PS > conda create -n py311 python=3.11
(base) PS > python -V Python 3.11.5 (base) > conda info -e # conda environments: # base * C:\Users\USER\anaconda3 py311 C:\Users\USER\anaconda3\envs\py311 py37 C:\Users\USER\anaconda3\envs\py37
(base) > conda activate py311 (py311) PS > conda info -e # conda environments: # base C:\Users\USER\anaconda3 py311 * C:\Users\USER\anaconda3\envs\py311 py37 C:\Users\USER\anaconda3\envs\py37
(py311) PS > conda install pip
(py37) PS > pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
(py311) PS > python -c "import torch" (py311) PS > python -c "import tkinter"※ エラーが出なければ OK
(py311) PS > python -c "import torch;print(torch.zeros(1).cuda())" tensor([0.], device='cuda:0') (py311) PS > python -c "import torch;print(torch.cuda.is_available())" True (py311) PS > python -c "import torch;print(torch.cuda.get_device_name(torch.device('cuda:0')))" NVIDIA GeForce RTX 4070 Ti
import torch print(torch.__version__) print(f"cuda, {torch.cuda.is_available()}") print(f"compute_{''.join(map(str,(torch.cuda.get_device_capability())))}") device_num:int = torch.cuda.device_count() print(f"find gpu devices, {device_num}") for idx in range(device_num): print(f"cuda:{idx}, {torch.cuda.get_device_name(idx)}") print("end")
(py311) PS > /anaconda_win/workspace_py311 (py311) PS > python cuda_test.py 2.1.2+cu121 cuda, True compute_89 find gpu devices, 1 cuda:0, NVIDIA GeForce RTX 4070 Ti end