LoginSignup
2
2

More than 3 years have passed since last update.

Windows で Blender 2.90 の python に Pytorch をインストールする

Last updated at Posted at 2020-10-19

基本的には Blender 2.8x にインストールするのと大差ないです。2.90 になってインストールできなくなるかと思いきや、予想以上にあっさり入りました。あんまり情報量ないですが、メモしておきます。

前提

  • Windows 10 Home/Pro
  • Blender 2.90

Blender は C:\Program Files\Blender Foundation にインストールされているものとします。CUDA や GPU のドライバはインストール済みとします。

手順

  1. PowerShell を管理者権限で開きます。
  2. pip を upgrade します。
  3. pytorch をインストールします。

こんだけです。

> cd C:\Program Files\Blender Foundation\Blender 2.90\2.90\python\bin

> ./python -m pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/cb/28/91f26bd088ce8e22169032100d4260614fc3da435025ff389ef1d396a433/pip-20.2.4-py2.py3-none-any.whl (1.5MB)
     |████████████████████████████████| 1.5MB 1.1MB/s
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-20.2.4

> ./python -m pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.6.0+cu101
  Downloading https://download.pytorch.org/whl/cu101/torch-1.6.0%2Bcu101-cp37-cp37m-win_amd64.whl (1021.6 MB)
     |████████████████████████████████| 1021.6 MB 750 bytes/s
...
Successfully installed future-0.18.2 pillow-8.0.0 torch-1.6.0+cu101 torchvision-0.7.0+cu101
>

Pytorch のインストールコマンドは、いつものように公式ページで CUDA のバージョンなどを選んで出てきたものをコピペするだけです。

image.png

ついでに pip で matplotlib など、必要なものをいれておきます。

> ./python -m pip install matplotlib            
Collecting matplotlib
  Downloading matplotlib-3.3.2-cp37-cp37m-win_amd64.whl (8.5 MB)
     |████████████████████████████████| 8.5 MB 1.3 MB/s
...
Successfully installed certifi-2020.6.20 cycler-0.10.0 kiwisolver-1.2.0 matplotlib-3.3.2 pyparsing-2.4.7 python-dateutil-2.8.1 six-1.15.0

Blender の python console でテスト

問題なくインストールされていれば、Blender の python console で import torch とか通ります。

image.png

ちなみに pytorch_example/mnist/main.py を実行しようとしたら、アクセス権限がないというエラーが出ました。一応これは、管理者権限で blender を実行することで回避はできます。ユーザがアクセスできるフォルダに blender をインストールすることでも回避できます。

2
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
2
2