LoginSignup
3
2

More than 5 years have passed since last update.

Bash on WindowsでPyTorchを使えるようにする。

Last updated at Posted at 2018-01-17

メインでWindowsを使っているのですがUbuntuでPyTorchを使う必要が出てきたので、Bash on WindowsにPyTorchをインストールしてみた。(2018年1月現在)PyTorchは0.3が最新のバージョンですが普段は0.2を使っているのでここからー>(http://pytorch.org/previous-versions/) 古いのを自分の環境に合わせてインストールする。
python3.5を使っているので、ターミナル上で次のコマンドを実行する。

pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whl
結果
$ pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whl
Collecting torch==0.2.0.post3 from http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whl
  Downloading http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whl (486.7MB)
    100% |████████████████████████████████| 486.7MB 6.4MB/s
Collecting pyyaml (from torch==0.2.0.post3)
  Downloading PyYAML-3.12.tar.gz (253kB)
    100% |████████████████████████████████| 256kB 2.3MB/s
Requirement already satisfied: numpy in /home/user/.pyenv/versions/3.5.1/lib/python3.5/site-packages (from torch==0.2.0.post3)
Installing collected packages: pyyaml, torch
  Running setup.py install for pyyaml ... done
Successfully installed pyyaml-3.12 torch-0.2.0.post3

これでBash on WindowsでもPyTorchが使えると思ったら、

$ python mnist.py
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
  File "mnist.py", line 5, in <module>
    import torch
  File "/home/user/.pyenv/versions/3.5.1/lib/python3.5/site-packages/torch/__init__.py", line 53, in <module>
    from torch._C import *
ImportError: numpy.core.multiarray failed to import

エラーがでた\(^o^)/
自分の環境の場合、以下のコマンドで解決しました。

$ pip install -U numpy

これでPyTorchが使えるようになりました。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2