[PYTHON] Install deep learning environment offline on Windows (Tensorflow, Keras) ・ ・ ・ It may be called "pip installation method in offline environment" ...

Why Windows? Why offline?

I think that the machine learning / deep learning environment is generally built on a Mac or Lunux that can connect to the Internet. However, due to circumstances, it became necessary to build an environment on a "Windows 7 machine" that was "offline (no internet connection)". Be wary only with Windows, but even offline. The reason for this is that it is necessary to handle highly sensitive data in data analysis projects, and it is not allowed to bring the data to the company or upload it to the cloud, so it is necessary to complete it all at the customer's site. Because there is. Isn't this a possible situation when trying to use deep learning for data analysis purposes? After a little research, all the information seems to be quite troublesome, and I have a feeling that it seems to fit.

If I write the conclusion first, ** it was easy. ** **

Tensorflow's ** installation on Windows ** itself is nothing special if you are in an online environment, and you can install it normally using pip or conda. Even in a proxy environment, there is no problem if you set proxy settings in environment variables and Anaconda configuration files. (I think you can find information as soon as you look it up, so I will omit it here.) It may be significant that we have officially supported Windows since Tensorflow reached 0.12 in November 2016. So, the point is ** what to do with offline installation **.

Only deep learning?

As you can see from the procedure after this, in the end it was just "offline execution of pip installation", so it is effective not only for deep learning libraries but also for ** pip installable packages in general **.

environment

Below, the machine for preparing the files required for installation will be referred to as the "online machine", and the machine to be installed will be referred to as the "offline machine". I think it would be good if the online and offline machines were Windows and Python 2 and 3 were compatible. (Perhaps)

--Windows 7 (without GPU)

For offline machines, install Anaconda in advance so that Python and pip can be used. Anaconda can be installed offline without any problems using the installer, so the procedure is omitted.

procedure

1. 1. Working on an online machine

** Work 1 ** Write the target libraries and packages in a file so that they can be processed together.

packages.txt


tensorflow
Keras

** Note: ** As mentioned above, the latest version of Tensorflow at the time of writing is 1.0, so if you do not specify the version as described above, you will install the latest 1.0. To specify a past version, do as follows.

packages.txt


tensorflow==0.12.0
Keras==1.1.2

Dependencies will be resolved on your own, so you only have to write what you need directly. Of course, regardless of deep learning, other packages can be installed, so if you need it, please write it together as appropriate. If you have a lot of things you want to install, it is efficient to edit the following execution result file.

pip freeze > packages.txt

** Work 2 ** Execute the following pip command. Here, only download without installing the library.

REM pip install --I get a warning when it is download
pip download -d <File output destination directory> -r packages.txt

This will download not only the specified ones, but also the ones with dependencies as .whl and .tar.gz files.

2. Working on an offline machine

** Work 1 ** Copy the file and packages.txt downloaded on the online machine to the offline machine.

** Work 2 ** Execute the following command.

REM C:\temp\aaa\OK with common Windows path notation like bbb
set package_dir=<Downloaded package file directory>
pip install --no-index --find-links=file://%package_dir% -r packages.txt

If you have Anaconda installed in advance, you don't need to install anything else. No build environment was required.

What about Chainer?

Chainer does not officially support Windows, but it seems that it can be done in the same way if other conditions such as build environment are prepared. It has not been confirmed at this time, so we will confirm it soon. However, if you use it for business, it may be a condition that it is officially supported, not just whether it can be used. It's a problem if you use something that is not supported and it doesn't work properly where you don't know.

Recommended Posts

Install deep learning environment offline on Windows (Tensorflow, Keras) ・ ・ ・ It may be called "pip installation method in offline environment" ...
How to install the deep learning framework Tensorflow 1.0 in the Anaconda environment of Windows
Install Jupiter Notebook on Windows with pip in proxy environment
Until you install TensorFlow-GPU with pip in Windows environment
Pip install in proxy environment
[Tensorflow] Tensorflow environment construction on Windows 10
Pip install (Windows) under Proxy environment
Pip install --ugrade pip fails on Windows
Install python2.7 on windows 32bit environment
install tensorflow in anaconda + python3.5 environment
UnicodeDecodeError occurs in pip (Windows environment)
Install easy_install and pip on windows
How to install Deep Learning framework Caffe on Mac in CPU mode