使用windows上 mxnet 預編譯版本


操作系統:

  64位Windows10

 

mxnet的Windows預編譯版本:下載地址

  分為不支持GPUs和支持GPUs版並,一般選擇GPUs版本。

  將下載的壓縮包解壓,比如解壓到D:\mxnet。然后雙擊執行,目錄下的 setupenv.cmd 文件,即設置好環境。

 

語言包安裝:

  下載安裝安裝python:下載地址

  執行如下命令安裝 numpy包:

pip install numpy

  設置環境變量:

    假設mxnet是解壓在D:\mxnet,則設置 PYTHONPATH=d:\mxnet\python

  語言支持,安裝完畢。

 

測試安裝是否正常:

  安裝wget:(運行案例腳本 train_mnist.py,要使用到)

    下載地址

    設置好環境變量,將wget加入PATH查找路徑。

  下載mxnet源代碼:

    直接下載源代碼包:下載地址

      解壓壓縮包。

    或者通過如下git命令下載

git clone --recursive https://github.com/dmlc/mxnet

    修改目錄下的 python example/image-classification/train_mnist.py 文件,將 此文件的第七行開始的 _download() 函數,修改為如下,保存:

def _download(data_dir):    
    ## fix for windows
    data_dir = data_dir.replace("/", "")
    if not os.path.isdir(data_dir):
        os.system("mkdir " + data_dir)
    os.chdir(data_dir)

    ## fix for windows
    if (not os.path.exists('mnist.zip')):
        os.system("wget http://webdocs.cs.ualberta.ca/~bx3/data/mnist.zip")

    if (not os.path.exists('train-images-idx3-ubyte')) or \
       (not os.path.exists('train-labels-idx1-ubyte')) or \
       (not os.path.exists('t10k-images-idx3-ubyte')) or \
       (not os.path.exists('t10k-labels-idx1-ubyte')):    
     ## fix for windows os.system("unzip -u mnist.zip") ## os.system("unzip -u mnist.zip; rm mnist.zip") os.chdir("..")

 

  在train_mnist.py腳本中,由於使用了linux的系統命令,所以必須修改。由於我的系統已安裝了git,所以有unzip命令,但缺少wget,故安裝wget。

 

  打開命令提示符執行命令:

  cpu only:

python example/image-classification/train_mnist.py

  GPUs計算:

python example/image-classification/train_mnist.py --network lenet --gpus 0

  

  如果執行正常,則恭喜你,可以使用mxnet開發程序了。

    

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM