So I want to install pytorch as a third party library with blender’s packaged python which is 3.7.0 I was wondering if any of you guys uses Blender and managed it to get this to work? Can you please share your methods? Installing torch in Blender would fail and tell me I should install torch with miniconda instead. Can someone help a fellow out? I am pulling my hairs out right now.
Edited:
Here is what I did to make pytorch work with Blender. Hopefully, this will help someone in the future.
I use Blender 2.8 which supposedly comes with its own python 3 and pip. The current python 3 version is 3.7 for my blender 2.8. What I did was install pytorch directly into Blender. Here are the steps.
Download and install Blender 2.8 beta
Go to your PATH from windows 10 system environment variables panel and find your Blender 2.8 installation directory then add it to PATH. For me this is
!IMPORTANT! Blender 2.8 now comes with a pre-installed Numpy and you need to go to Blender 2.8 site-packages dir and change the folder name. If you don’t do this after you install Pytorch it will fail. Pytorch will install another version on top of the pre existing Numpy causing version issues. The folder location of numpy and other packages is:
D:\Blender…\2.80\python\lib\site-packages\
Now you can go to the main Pytorch site and pick the correct pip3 installation instruction to run. Make sure the python version matches with Blender and not with other versions of python you have already installed. To make sure everything installed correctly you should open Blender 2.8 click on the scripting tab on top and try to import torch. If no error is shown you are now good to go.
(In both cases making sure to run the python binary that’s distributed with Blender itself)
I checked the instructions here to confirm the appropriate pytorch wheel url for Linux/Windows and Python 3.7 (matching the version distributed with Blender).
It hardly matters but I chose to generally install everything outside of Blender’s site-packages via --user just to minimize my modifications to the based installation of Blender.
I’ve created a dedicated library as part of a research for this purpose:
It creates N-instances of Blender, streaming via ZMQ directly into a PyTorch dataset. The related paper is here https://arxiv.org/abs/1907.01879. We used it massively generate Blender renderings for online training of a model. Additionally we created a control channel that allows the simulation to update to training needs.
Work was done for Blender 2.79, but we expect a major leap in performance when switching to 2.80 and EEVEE rendering engine. However, I haven’t looked into image streaming from EEVEE works yet.