9

Unity – ml-agents 環境準備2 – 安裝 – NaCl's Blog

 3 years ago
source link: https://naclyen.com/2018/05/07/unity-ml-agents-%e7%92%b0%e5%a2%83%e6%ba%96%e5%82%992-%e5%ae%89%e8%a3%9d/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Unity – ml-agents 環境準備2 – 安裝 – NaCl's Blog

一直找不到時間弄個圖文版, 拖到現在就直接用文字帶過囉~ 哈哈!!

延續上一篇確認版本之後就可以開始安裝了~

這裡假設你是要用到 Nvidia 的 gpu 運算.

以下以 ml-agents v3.0 on win10 的版本為範例, 所需的版本是 TensorFlow 1.4.0 & TensorFlow-gpu 1.4.0 & CUDA 8 & cuDNN 6(for CUDA 8).

  1. 安裝 CUDA 8 & cuDNN 6(for CUDA 8).
  2. 安裝 Anaconda(理論上版本不限).
  3. 在 Anaconda 產生新"環境".
  4. 在該環境中安裝所需元件(TensorFlow, TensorFlow-gpu, …等等).

1 & 2的步驟都只是一般軟體安裝就不贅述, 請直接參考官方文件 or Unity Taiwan 的攻略
※版本很重要! 版本很重要! 版本很重要!

開啟 Anaconda Prompt(建議直接用管理者權限開啟).

產生"環境"並安裝python 3.6版
(base) C:\Users\xxx>conda create -n ml-agents python=3.6

啟用"環境", 從這開始 command line 的最前面會變成 (ml-agents) 開頭, 這是你處於名為 “ml-agents" 的 “環境" 底下的指標.
(base) C:\Users\xxx>conda activate ml-agents

透過 requirements.txt 安裝所需元件, 這裡假設把 ml-agents github 的專案放在 “D:\ml-agents".
pip install D:\ml-agents\python

另外手動安裝 tensorflow-gpu 1.4.0 版
(ml-agents) C:\Users\xxx>pip install tensorflow-gpu==1.4.0

到這裡其實就安裝完成了!

接著要要用來驗證環境是否正確的, 嘗試在 python 裡面 import tensorflow.

啟動 python, 如果有重開, 記得先用 conda activate 切換到正確的環境.
(ml-agents) C:\WINDOWS\system32>python

import TensFlow
>>> import tensorflow as tf

如果沒有跳出任何訊息就是好消息!!
反之出現一大串 Excpetion 之類的訊息就是有過程失誤了~

goodluck!!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK