Importing external library TensorFlow into Slicer

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Importing external library TensorFlow into Slicer

prisgdd
Hi all, 


I am actually working on a project using TensorFlow and I would like to include that library into Slicer, as I developed an extension for it. 
For my preliminary tests, I was able to compile Slicer against an Anaconda environment, which contains TensorFlow, python2.7 and uses an independent Numpy. 

Now, I would like to deploy my extension. I wanted to try first on a nightly or custom version of Slicer. 
I installed pip into Slicer and I used it to install TensorFlow and its dependencies. That worked, and I was able to import TensorFlow from the Slicer Python interactor. 
Then, I added the path to my extension in Slicer and when it restarted, the following error appeared: 


>>> Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/Classification.py", line 12, in <module>

import neuralNetwork as nn

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>

import tensorflow as tf

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

from tensorflow.python import *

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 118, in <module>

from tensorflow.python.platform import app

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 23, in <module>

from tensorflow.python.platform import flags

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 25, in <module>

_global_parser = _argparse.ArgumentParser()

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/argparse.py", line 1586, in __init__

prog = _os.path.basename(_sys.argv[0])

AttributeError: 'module' object has no attribute 'argv'

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>

import tensorflow as tf

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

from tensorflow.python import *

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>

raise ImportError(msg)

ImportError: Traceback (most recent call last):

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>

from tensorflow.python import pywrap_tensorflow

ImportError: cannot import name pywrap_tensorflow



Failed to load the native TensorFlow runtime.



From what I found on Google, this error usually appears when you import TensorFlow from the folder you downloaded it, but in my case that makes no sense because I installed it into Slicer from the Slicer Python interactor.

Do you have any idea?


Best, 

Priscille de Dumast
University of Michigan




_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing external library TensorFlow into Slicer

Steve Pieper-2
Hi Priscille - 

Unfortunately it's not possible to mix the python packages between Slicer binary downloads and anaconda.  Folks have been looking at it for a while [1].

One option is to run the tensorflow code in another process, or even in a docker image [2] so that you can use any dependencies independent of Slicer's python constraints.

Hope that helps,
Steve



On Mon, Mar 27, 2017 at 7:25 PM, Priscille Guerrier de Dumast <[hidden email]> wrote:
Hi all, 


I am actually working on a project using TensorFlow and I would like to include that library into Slicer, as I developed an extension for it. 
For my preliminary tests, I was able to compile Slicer against an Anaconda environment, which contains TensorFlow, python2.7 and uses an independent Numpy. 

Now, I would like to deploy my extension. I wanted to try first on a nightly or custom version of Slicer. 
I installed pip into Slicer and I used it to install TensorFlow and its dependencies. That worked, and I was able to import TensorFlow from the Slicer Python interactor. 
Then, I added the path to my extension in Slicer and when it restarted, the following error appeared: 


>>> Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/Classification.py", line 12, in <module>

import neuralNetwork as nn

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>

import tensorflow as tf

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

from tensorflow.python import *

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 118, in <module>

from tensorflow.python.platform import app

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 23, in <module>

from tensorflow.python.platform import flags

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 25, in <module>

_global_parser = _argparse.ArgumentParser()

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/argparse.py", line 1586, in __init__

prog = _os.path.basename(_sys.argv[0])

AttributeError: 'module' object has no attribute 'argv'

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>

import tensorflow as tf

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

from tensorflow.python import *

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>

raise ImportError(msg)

ImportError: Traceback (most recent call last):

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>

from tensorflow.python import pywrap_tensorflow

ImportError: cannot import name pywrap_tensorflow



Failed to load the native TensorFlow runtime.



From what I found on Google, this error usually appears when you import TensorFlow from the folder you downloaded it, but in my case that makes no sense because I installed it into Slicer from the Slicer Python interactor.

Do you have any idea?


Best, 

Priscille de Dumast
University of Michigan




_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing external library TensorFlow into Slicer

prisgdd
In reply to this post by prisgdd
Thank you very much Steve, that helps a lot! 
I started to work on an independent process for the part requiring TensorFlow, and implement it on a Docker Image.

Regarding its usage, is it possible to run a Docker image from a Slicer extension, or should I plan run it on a server, as it's done in the DeepInfer project?

Thanks a lot, 

Best,
Priscille



On Sun, Apr 2, 2017 at 3:07 PM, Steve Pieper <[hidden email]> wrote:
Hi Priscille - 

Unfortunately it's not possible to mix the python packages between Slicer binary downloads and anaconda.  Folks have been looking at it for a while [1].

One option is to run the tensorflow code in another process, or even in a docker image [2] so that you can use any dependencies independent of Slicer's python constraints.

Hope that helps,
Steve



On Mon, Mar 27, 2017 at 7:25 PM, Priscille Guerrier de Dumast <[hidden email]> wrote:
Hi all, 


I am actually working on a project using TensorFlow and I would like to include that library into Slicer, as I developed an extension for it. 
For my preliminary tests, I was able to compile Slicer against an Anaconda environment, which contains TensorFlow, python2.7 and uses an independent Numpy. 

Now, I would like to deploy my extension. I wanted to try first on a nightly or custom version of Slicer. 
I installed pip into Slicer and I used it to install TensorFlow and its dependencies. That worked, and I was able to import TensorFlow from the Slicer Python interactor. 
Then, I added the path to my extension in Slicer and when it restarted, the following error appeared: 


>>> Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/Classification.py", line 12, in <module>

import neuralNetwork as nn

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>

import tensorflow as tf

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

from tensorflow.python import *

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 118, in <module>

from tensorflow.python.platform import app

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 23, in <module>

from tensorflow.python.platform import flags

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 25, in <module>

_global_parser = _argparse.ArgumentParser()

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/argparse.py", line 1586, in __init__

prog = _os.path.basename(_sys.argv[0])

AttributeError: 'module' object has no attribute 'argv'

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>

import tensorflow as tf

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

from tensorflow.python import *

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>

raise ImportError(msg)

ImportError: Traceback (most recent call last):

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>

from tensorflow.python import pywrap_tensorflow

ImportError: cannot import name pywrap_tensorflow



Failed to load the native TensorFlow runtime.



From what I found on Google, this error usually appears when you import TensorFlow from the folder you downloaded it, but in my case that makes no sense because I installed it into Slicer from the Slicer Python interactor.

Do you have any idea?


Best, 

Priscille de Dumast
University of Michigan




_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ



_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing external library TensorFlow into Slicer

Steve Pieper-2
In reply to this post by prisgdd
Hi Priscille - 

You could certainly run the docker image from slicer by invoking the run command.  Of course the user will need to have docker installed on their system for it to work.  Most users would technically be able to install docker, but I understand some windows systems require a change to a bios setting and that might make it hard for people to use it.  Running in a separate process, perhaps a virtualenv or similar is probably the most easily deployable.

Best,
Steve

On Wed, Apr 5, 2017 at 12:50 PM, Priscille Guerrier de Dumast <[hidden email]> wrote:
Thank you very much Steve, that helps a lot! 
I started to work on an independent process for the part requiring TensorFlow, and implement it on a Docker Image.

Regarding its usage, is it possible to run a Docker image from a Slicer extension, or should I plan run it on a server, as it's done in the DeepInfer project?

Thanks a lot, 

Best,
Priscille



On Sun, Apr 2, 2017 at 3:07 PM, Steve Pieper <[hidden email]> wrote:
Hi Priscille - 

Unfortunately it's not possible to mix the python packages between Slicer binary downloads and anaconda.  Folks have been looking at it for a while [1].

One option is to run the tensorflow code in another process, or even in a docker image [2] so that you can use any dependencies independent of Slicer's python constraints.

Hope that helps,
Steve



On Mon, Mar 27, 2017 at 7:25 PM, Priscille Guerrier de Dumast <[hidden email]> wrote:
Hi all, 


I am actually working on a project using TensorFlow and I would like to include that library into Slicer, as I developed an extension for it. 
For my preliminary tests, I was able to compile Slicer against an Anaconda environment, which contains TensorFlow, python2.7 and uses an independent Numpy. 

Now, I would like to deploy my extension. I wanted to try first on a nightly or custom version of Slicer. 
I installed pip into Slicer and I used it to install TensorFlow and its dependencies. That worked, and I was able to import TensorFlow from the Slicer Python interactor. 
Then, I added the path to my extension in Slicer and when it restarted, the following error appeared: 


>>> Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/Classification.py", line 12, in <module>

import neuralNetwork as nn

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>

import tensorflow as tf

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

from tensorflow.python import *

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 118, in <module>

from tensorflow.python.platform import app

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 23, in <module>

from tensorflow.python.platform import flags

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 25, in <module>

_global_parser = _argparse.ArgumentParser()

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/argparse.py", line 1586, in __init__

prog = _os.path.basename(_sys.argv[0])

AttributeError: 'module' object has no attribute 'argv'

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>

import tensorflow as tf

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

from tensorflow.python import *

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>

raise ImportError(msg)

ImportError: Traceback (most recent call last):

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>

from tensorflow.python import pywrap_tensorflow

ImportError: cannot import name pywrap_tensorflow



Failed to load the native TensorFlow runtime.



From what I found on Google, this error usually appears when you import TensorFlow from the folder you downloaded it, but in my case that makes no sense because I installed it into Slicer from the Slicer Python interactor.

Do you have any idea?


Best, 

Priscille de Dumast
University of Michigan




_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ




_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing external library TensorFlow into Slicer

lasso2

Installing Docker on Windows 10 is really easy, just download and run the installer. By default you don’t need to change any system settings, as Hyper-V is already included in the operating system and all necessary BIOS settings are enabled by default.

 

I think setup was more complicated earlier because docker used Oracle VirtualBox – but now Hyper-V is the default.

 

Andras

 

From: slicer-devel [mailto:[hidden email]] On Behalf Of Steve Pieper
Sent: April 5, 2017 14:09
To: Priscille Guerrier de Dumast <[hidden email]>
Cc: SPL Slicer Devel <[hidden email]>
Subject: Re: [slicer-devel] Importing external library TensorFlow into Slicer

 

Hi Priscille - 

 

You could certainly run the docker image from slicer by invoking the run command.  Of course the user will need to have docker installed on their system for it to work.  Most users would technically be able to install docker, but I understand some windows systems require a change to a bios setting and that might make it hard for people to use it.  Running in a separate process, perhaps a virtualenv or similar is probably the most easily deployable.

 

Best,

Steve

 

On Wed, Apr 5, 2017 at 12:50 PM, Priscille Guerrier de Dumast <[hidden email]> wrote:

Thank you very much Steve, that helps a lot! 

I started to work on an independent process for the part requiring TensorFlow, and implement it on a Docker Image.


Regarding its usage, is it possible to run a Docker image from a Slicer extension, or should I plan run it on a server, as it's done in the DeepInfer project?

 

Thanks a lot, 

 

Best,

Priscille

 

 

 

On Sun, Apr 2, 2017 at 3:07 PM, Steve Pieper <[hidden email]> wrote:

Hi Priscille - 

 

Unfortunately it's not possible to mix the python packages between Slicer binary downloads and anaconda.  Folks have been looking at it for a while [1].

 

One option is to run the tensorflow code in another process, or even in a docker image [2] so that you can use any dependencies independent of Slicer's python constraints.

 

Hope that helps,

Steve

 

 

 

On Mon, Mar 27, 2017 at 7:25 PM, Priscille Guerrier de Dumast <[hidden email]> wrote:

Hi all, 

 

 

I am actually working on a project using TensorFlow and I would like to include that library into Slicer, as I developed an extension for it. 

For my preliminary tests, I was able to compile Slicer against an Anaconda environment, which contains TensorFlow, python2.7 and uses an independent Numpy. 

 

Now, I would like to deploy my extension. I wanted to try first on a nightly or custom version of Slicer. 

I installed pip into Slicer and I used it to install TensorFlow and its dependencies. That worked, and I was able to import TensorFlow from the Slicer Python interactor. 

Then, I added the path to my extension in Slicer and when it restarted, the following error appeared: 

 

 

>>> Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/Classification.py", line 12, in <module>

import neuralNetwork as nn

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>

import tensorflow as tf

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

from tensorflow.python import *

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 118, in <module>

from tensorflow.python.platform import app

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 23, in <module>

from tensorflow.python.platform import flags

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 25, in <module>

_global_parser = _argparse.ArgumentParser()

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/argparse.py", line 1586, in __init__

prog = _os.path.basename(_sys.argv[0])

AttributeError: 'module' object has no attribute 'argv'

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>

import tensorflow as tf

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

from tensorflow.python import *

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>

raise ImportError(msg)

ImportError: Traceback (most recent call last):

File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>

from tensorflow.python import pywrap_tensorflow

ImportError: cannot import name pywrap_tensorflow

 

 

Failed to load the native TensorFlow runtime.

 

 

From what I found on Google, this error usually appears when you import TensorFlow from the folder you downloaded it, but in my case that makes no sense because I installed it into Slicer from the Slicer Python interactor.

 

Do you have any idea?

 

 

Best, 

 

Priscille de Dumast

University of Michigan

 

 

 

 

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ

 

 

 


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing external library TensorFlow into Slicer

andrey.fedorov
On Wed, Apr 5, 2017 at 4:23 PM, Andras Lasso <[hidden email]> wrote:
> Installing Docker on Windows 10 is really easy, just download and run the
> installer. By default you don’t need to change any system settings, as
> Hyper-V is already included in the operating system and all necessary BIOS
> settings are enabled by default.
>

It really depends on the system. On the desktop I have in my office, I
had to change the BIOS settings to be able to use the latest docker.

>
>
> I think setup was more complicated earlier because docker used Oracle
> VirtualBox – but now Hyper-V is the default.
>
>
>
> Andras
>
>
>
> From: slicer-devel [mailto:[hidden email]] On Behalf
> Of Steve Pieper
> Sent: April 5, 2017 14:09
> To: Priscille Guerrier de Dumast <[hidden email]>
> Cc: SPL Slicer Devel <[hidden email]>
> Subject: Re: [slicer-devel] Importing external library TensorFlow into
> Slicer
>
>
>
> Hi Priscille -
>
>
>
> You could certainly run the docker image from slicer by invoking the run
> command.  Of course the user will need to have docker installed on their
> system for it to work.  Most users would technically be able to install
> docker, but I understand some windows systems require a change to a bios
> setting and that might make it hard for people to use it.  Running in a
> separate process, perhaps a virtualenv or similar is probably the most
> easily deployable.
>
>
>
> Best,
>
> Steve
>
>
>
> On Wed, Apr 5, 2017 at 12:50 PM, Priscille Guerrier de Dumast
> <[hidden email]> wrote:
>
> Thank you very much Steve, that helps a lot!
>
> I started to work on an independent process for the part requiring
> TensorFlow, and implement it on a Docker Image.
>
>
> Regarding its usage, is it possible to run a Docker image from a Slicer
> extension, or should I plan run it on a server, as it's done in the
> DeepInfer project?
>
>
>
> Thanks a lot,
>
>
>
> Best,
>
> Priscille
>
>
>
>
>
>
>
> On Sun, Apr 2, 2017 at 3:07 PM, Steve Pieper <[hidden email]> wrote:
>
> Hi Priscille -
>
>
>
> Unfortunately it's not possible to mix the python packages between Slicer
> binary downloads and anaconda.  Folks have been looking at it for a while
> [1].
>
>
>
> One option is to run the tensorflow code in another process, or even in a
> docker image [2] so that you can use any dependencies independent of
> Slicer's python constraints.
>
>
>
> Hope that helps,
>
> Steve
>
>
>
> [1] https://www.slicer.org/wiki/Documentation/Labs/SlicerCondaIntegration
>
>
>
> [2] https://www.na-mic.org/Wiki/index.php/2017_Winter_Project_Week/DeepInfer
>
>
>
> On Mon, Mar 27, 2017 at 7:25 PM, Priscille Guerrier de Dumast
> <[hidden email]> wrote:
>
> Hi all,
>
>
>
>
>
> I am actually working on a project using TensorFlow and I would like to
> include that library into Slicer, as I developed an extension for it.
>
> For my preliminary tests, I was able to compile Slicer against an Anaconda
> environment, which contains TensorFlow, python2.7 and uses an independent
> Numpy.
>
>
>
> Now, I would like to deploy my extension. I wanted to try first on a nightly
> or custom version of Slicer.
>
> I installed pip into Slicer and I used it to install TensorFlow and its
> dependencies. That worked, and I was able to import TensorFlow from the
> Slicer Python interactor.
>
> Then, I added the path to my extension in Slicer and when it restarted, the
> following error appeared:
>
>
>
>
>
>>>> Traceback (most recent call last):
>
> File "<string>", line 1, in <module>
>
> File
> "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/Classification.py",
> line 12, in <module>
>
> import neuralNetwork as nn
>
> File
> "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py",
> line 7, in <module>
>
> import tensorflow as tf
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py",
> line 24, in <module>
>
> from tensorflow.python import *
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py",
> line 118, in <module>
>
> from tensorflow.python.platform import app
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/app.py",
> line 23, in <module>
>
> from tensorflow.python.platform import flags
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/flags.py",
> line 25, in <module>
>
> _global_parser = _argparse.ArgumentParser()
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/argparse.py",
> line 1586, in __init__
>
> prog = _os.path.basename(_sys.argv[0])
>
> AttributeError: 'module' object has no attribute 'argv'
>
> Traceback (most recent call last):
>
> File "<string>", line 1, in <module>
>
> File
> "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py",
> line 7, in <module>
>
> import tensorflow as tf
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py",
> line 24, in <module>
>
> from tensorflow.python import *
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py",
> line 72, in <module>
>
> raise ImportError(msg)
>
> ImportError: Traceback (most recent call last):
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py",
> line 61, in <module>
>
> from tensorflow.python import pywrap_tensorflow
>
> ImportError: cannot import name pywrap_tensorflow
>
>
>
>
>
> Failed to load the native TensorFlow runtime.
>
>
>
>
>
> From what I found on Google, this error usually appears when you import
> TensorFlow from the folder you downloaded it, but in my case that makes no
> sense because I installed it into Slicer from the Slicer Python interactor.
>
>
>
> Do you have any idea?
>
>
>
>
>
> Best,
>
>
>
> Priscille de Dumast
>
> University of Michigan
>
>
>
>
>
>
>
>
>
> _______________________________________________
> slicer-devel mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
> To unsubscribe: send email to [hidden email] with
> unsubscribe as the subject
> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>
>
>
>
>
>
>
>
> _______________________________________________
> slicer-devel mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
> To unsubscribe: send email to [hidden email] with
> unsubscribe as the subject
> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing external library TensorFlow into Slicer

lasso2
In reply to this post by lasso2

Ok, on some computers you may need to enable virtualization, but it is usually takes just minutes (maybe 5-10 minutes if you have never changed BIOS/UEFI settings before and you need to find a webpage that explains how to do it). Even with this, the overall setup procedure is really straightforward.

Andras

 

From: [hidden email]
Sent: Wednesday, April 5, 2017 11:23 PM
To: [hidden email]
Cc: [hidden email]; [hidden email]; [hidden email]
Subject: Re: [slicer-devel] Importing external library TensorFlow into Slicer

 

On Wed, Apr 5, 2017 at 4:23 PM, Andras Lasso <[hidden email]> wrote:
> Installing Docker on Windows 10 is really easy, just download and run the
> installer. By default you don’t need to change any system settings, as
> Hyper-V is already included in the operating system and all necessary BIOS
> settings are enabled by default.
>

It really depends on the system. On the desktop I have in my office, I
had to change the BIOS settings to be able to use the latest docker.

>
>
> I think setup was more complicated earlier because docker used Oracle
> VirtualBox – but now Hyper-V is the default.
>
>
>
> Andras
>
>
>
> From: slicer-devel [[hidden email]] On Behalf
> Of Steve Pieper
> Sent: April 5, 2017 14:09
> To: Priscille Guerrier de Dumast <[hidden email]>
> Cc: SPL Slicer Devel <[hidden email]>
> Subject: Re: [slicer-devel] Importing external library TensorFlow into
> Slicer
>
>
>
> Hi Priscille -
>
>
>
> You could certainly run the docker image from slicer by invoking the run
> command.  Of course the user will need to have docker installed on their
> system for it to work.  Most users would technically be able to install
> docker, but I understand some windows systems require a change to a bios
> setting and that might make it hard for people to use it.  Running in a
> separate process, perhaps a virtualenv or similar is probably the most
> easily deployable.
>
>
>
> Best,
>
> Steve
>
>
>
> On Wed, Apr 5, 2017 at 12:50 PM, Priscille Guerrier de Dumast
> <[hidden email]> wrote:
>
> Thank you very much Steve, that helps a lot!
>
> I started to work on an independent process for the part requiring
> TensorFlow, and implement it on a Docker Image.
>
>
> Regarding its usage, is it possible to run a Docker image from a Slicer
> extension, or should I plan run it on a server, as it's done in the
> DeepInfer project?
>
>
>
> Thanks a lot,
>
>
>
> Best,
>
> Priscille
>
>
>
>
>
>
>
> On Sun, Apr 2, 2017 at 3:07 PM, Steve Pieper <[hidden email]> wrote:
>
> Hi Priscille -
>
>
>
> Unfortunately it's not possible to mix the python packages between Slicer
> binary downloads and anaconda.  Folks have been looking at it for a while
> [1].
>
>
>
> One option is to run the tensorflow code in another process, or even in a
> docker image [2] so that you can use any dependencies independent of
> Slicer's python constraints.
>
>
>
> Hope that helps,
>
> Steve
>
>
>
> [1] https://www.slicer.org/wiki/Documentation/Labs/SlicerCondaIntegration
>
>
>
> [2] https://www.na-mic.org/Wiki/index.php/2017_Winter_Project_Week/DeepInfer
>
>
>
> On Mon, Mar 27, 2017 at 7:25 PM, Priscille Guerrier de Dumast
> <[hidden email]> wrote:
>
> Hi all,
>
>
>
>
>
> I am actually working on a project using TensorFlow and I would like to
> include that library into Slicer, as I developed an extension for it.
>
> For my preliminary tests, I was able to compile Slicer against an Anaconda
> environment, which contains TensorFlow, python2.7 and uses an independent
> Numpy.
>
>
>
> Now, I would like to deploy my extension. I wanted to try first on a nightly
> or custom version of Slicer.
>
> I installed pip into Slicer and I used it to install TensorFlow and its
> dependencies. That worked, and I was able to import TensorFlow from the
> Slicer Python interactor.
>
> Then, I added the path to my extension in Slicer and when it restarted, the
> following error appeared:
>
>
>
>
>
>>>> Traceback (most recent call last):
>
> File "<string>", line 1, in <module>
>
> File
> "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/Classification.py",
> line 12, in <module>
>
> import neuralNetwork as nn
>
> File
> "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py",
> line 7, in <module>
>
> import tensorflow as tf
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py",
> line 24, in <module>
>
> from tensorflow.python import *
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py",
> line 118, in <module>
>
> from tensorflow.python.platform import app
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/app.py",
> line 23, in <module>
>
> from tensorflow.python.platform import flags
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/flags.py",
> line 25, in <module>
>
> _global_parser = _argparse.ArgumentParser()
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/argparse.py",
> line 1586, in __init__
>
> prog = _os.path.basename(_sys.argv[0])
>
> AttributeError: 'module' object has no attribute 'argv'
>
> Traceback (most recent call last):
>
> File "<string>", line 1, in <module>
>
> File
> "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py",
> line 7, in <module>
>
> import tensorflow as tf
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py",
> line 24, in <module>
>
> from tensorflow.python import *
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py",
> line 72, in <module>
>
> raise ImportError(msg)
>
> ImportError: Traceback (most recent call last):
>
> File
> "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py",
> line 61, in <module>
>
> from tensorflow.python import pywrap_tensorflow
>
> ImportError: cannot import name pywrap_tensorflow
>
>
>
>
>
> Failed to load the native TensorFlow runtime.
>
>
>
>
>
> From what I found on Google, this error usually appears when you import
> TensorFlow from the folder you downloaded it, but in my case that makes no
> sense because I installed it into Slicer from the Slicer Python interactor.
>
>
>
> Do you have any idea?
>
>
>
>
>
> Best,
>
>
>
> Priscille de Dumast
>
> University of Michigan
>
>
>
>
>
>
>
>
>
> _______________________________________________
> slicer-devel mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
> To unsubscribe: send email to [hidden email] with
> unsubscribe as the subject
> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>
>
>
>
>
>
>
>
> _______________________________________________
> slicer-devel mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
> To unsubscribe: send email to [hidden email] with
> unsubscribe as the subject
> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing external library TensorFlow into Slicer

Lowekamp, Bradley (NIH/NLM/LHC) [C]
In reply to this post by lasso2
Hello,

Not everyone is easily able to install system packages on a a windows systems. Use a full docker image may be more heavy weight than needed. It could be possible to have two Python stacks one for Slicer internals and another compatible with Python Packaging Authority’s standards or MiniConda.

Is there any document/discussion about the reasons why Slicer’s Python is not ABI compatible with PyPi? I’d expect OS X and linux to be reasonable easy to do, but windows would require matching the PPA’s compiler for the python release i.e Py27->VS9, Py34->VS10 etc.

Brad

P.S. SlimpleITK’s situation was very different because of it’s dependencies on ITK, and needing to include Slicers IO extensions. 

On Apr 5, 2017, at 4:23 PM, Andras Lasso <[hidden email]> wrote:

Installing Docker on Windows 10 is really easy, just download and run the installer. By default you don’t need to change any system settings, as Hyper-V is already included in the operating system and all necessary BIOS settings are enabled by default.
 
I think setup was more complicated earlier because docker used Oracle VirtualBox – but now Hyper-V is the default.
 
Andras
 
From: slicer-devel [[hidden email]] On Behalf Of Steve Pieper
Sent: April 5, 2017 14:09
To: Priscille Guerrier de Dumast <[hidden email]>
Cc: SPL Slicer Devel <[hidden email]>
Subject: Re: [slicer-devel] Importing external library TensorFlow into Slicer
 
Hi Priscille -  
 
You could certainly run the docker image from slicer by invoking the run command.  Of course the user will need to have docker installed on their system for it to work.  Most users would technically be able to install docker, but I understand some windows systems require a change to a bios setting and that might make it hard for people to use it.  Running in a separate process, perhaps a virtualenv or similar is probably the most easily deployable.
 
Best,
Steve
 
On Wed, Apr 5, 2017 at 12:50 PM, Priscille Guerrier de Dumast <[hidden email]> wrote:
Thank you very much Steve, that helps a lot!  
I started to work on an independent process for the part requiring TensorFlow, and implement it on a Docker Image.

Regarding its usage, is it possible to run a Docker image from a Slicer extension, or should I plan run it on a server, as it's done in the DeepInfer project?
 
Thanks a lot, 
 
Best,
Priscille
 
 
 
On Sun, Apr 2, 2017 at 3:07 PM, Steve Pieper <[hidden email]> wrote:
Hi Priscille -  
 
Unfortunately it's not possible to mix the python packages between Slicer binary downloads and anaconda.  Folks have been looking at it for a while [1].
 
One option is to run the tensorflow code in another process, or even in a docker image [2] so that you can use any dependencies independent of Slicer's python constraints.
 
Hope that helps,
Steve
 
 
 
On Mon, Mar 27, 2017 at 7:25 PM, Priscille Guerrier de Dumast <[hidden email]> wrote:
Hi all,  
 
 
I am actually working on a project using TensorFlow and I would like to include that library into Slicer, as I developed an extension for it. 
For my preliminary tests, I was able to compile Slicer against an Anaconda environment, which contains TensorFlow, python2.7 and uses an independent Numpy. 
 
Now, I would like to deploy my extension. I wanted to try first on a nightly or custom version of Slicer. 
I installed pip into Slicer and I used it to install TensorFlow and its dependencies. That worked, and I was able to import TensorFlow from the Slicer Python interactor. 
Then, I added the path to my extension in Slicer and when it restarted, the following error appeared: 
 
 
>>> Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/Classification.py", line 12, in <module>
import neuralNetwork as nn
File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>
import tensorflow as tf
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 118, in <module>
from tensorflow.python.platform import app
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 23, in <module>
from tensorflow.python.platform import flags
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 25, in <module>
_global_parser = _argparse.ArgumentParser()
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/argparse.py", line 1586, in __init__
prog = _os.path.basename(_sys.argv[0])
AttributeError: 'module' object has no attribute 'argv'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>
import tensorflow as tf
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
 
 
Failed to load the native TensorFlow runtime.
 
 
From what I found on Google, this error usually appears when you import TensorFlow from the folder you downloaded it, but in my case that makes no sense because I installed it into Slicer from the Slicer Python interactor.
 
Do you have any idea?
 
 
Best, 
 
Priscille de Dumast
University of Michigan
 
 
 
 
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
 
 
 
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing external library TensorFlow into Slicer

prisgdd
Hello, 

Thanks for your advices! I finally opted for a virtualenv, as it would be much easier for the user to use it. 

The process I'd like to implement from my python script would follow those steps
1. get pip into Slicer 
2. install virtualenv using pip
3. create a virtualenv
4. install tensorflow in the virtualenv 

I tried different methods at each step that work more or less. 
I noticed than running the executable of virtualenv creates a new instance of 3DSlicer. So I run the python script virtualenv.py to create my virtualenv. 

If I run it using 'python-real', I have the following error: 

Traceback (most recent call last):

File "/Applications/Slicer.app/Contents/MacOS/../lib/Python/lib/python2.7/site-packages/virtualenv.py", line 20, in <module>

import shutil

File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/shutil.py", line 12, in <module>

import collections

File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/collections.py", line 8, in <module>

from _collections import deque, defaultdict

ImportError: No module named _collections




So I tried with 'SlicerPython', and was able to create my virtual environment. pip is installed by default when a new one is created. 
To install tensorflow in it, I activate the environment, and use pip module in python. I have the following error:

Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/site-packages/pip/__init__.py", line 5, in <module>

import logging

File "/Applications/Slicer.app/Contents/lib/Python/lib/python2.7/logging/__init__.py", line 26, in <module>

import sys, os, time, cStringIO, traceback, warnings, weakref, collections

ImportError: No module named time



I checked which python was used at this moment, and it was the good one from the environment. I also played a bit with all the paths and python options, but I always got stuck with import error, related to the slicer configuration. 

Did anyone ever create a virtualenv, and install packages in it from a python script in Slicer? 

Or if you have an idea about which settings I might be missing when working in my environment?


Thanks,

Priscille de Dumast
University of Michigan




On Thu, Apr 6, 2017 at 9:18 AM, Lowekamp, Bradley (NIH/NLM/LHC) [C] <[hidden email]> wrote:
Hello,

Not everyone is easily able to install system packages on a a windows systems. Use a full docker image may be more heavy weight than needed. It could be possible to have two Python stacks one for Slicer internals and another compatible with Python Packaging Authority’s standards or MiniConda.

Is there any document/discussion about the reasons why Slicer’s Python is not ABI compatible with PyPi? I’d expect OS X and linux to be reasonable easy to do, but windows would require matching the PPA’s compiler for the python release i.e Py27->VS9, Py34->VS10 etc.

Brad

P.S. SlimpleITK’s situation was very different because of it’s dependencies on ITK, and needing to include Slicers IO extensions. 

On Apr 5, 2017, at 4:23 PM, Andras Lasso <[hidden email]> wrote:

Installing Docker on Windows 10 is really easy, just download and run the installer. By default you don’t need to change any system settings, as Hyper-V is already included in the operating system and all necessary BIOS settings are enabled by default.
 
I think setup was more complicated earlier because docker used Oracle VirtualBox – but now Hyper-V is the default.
 
Andras
 
From: slicer-devel [[hidden email]] On Behalf Of Steve Pieper
Sent: April 5, 2017 14:09
To: Priscille Guerrier de Dumast <[hidden email]>
Cc: SPL Slicer Devel <[hidden email]>
Subject: Re: [slicer-devel] Importing external library TensorFlow into Slicer
 
Hi Priscille -  
 
You could certainly run the docker image from slicer by invoking the run command.  Of course the user will need to have docker installed on their system for it to work.  Most users would technically be able to install docker, but I understand some windows systems require a change to a bios setting and that might make it hard for people to use it.  Running in a separate process, perhaps a virtualenv or similar is probably the most easily deployable.
 
Best,
Steve
 
On Wed, Apr 5, 2017 at 12:50 PM, Priscille Guerrier de Dumast <[hidden email]> wrote:
Thank you very much Steve, that helps a lot!  
I started to work on an independent process for the part requiring TensorFlow, and implement it on a Docker Image.

Regarding its usage, is it possible to run a Docker image from a Slicer extension, or should I plan run it on a server, as it's done in the DeepInfer project?
 
Thanks a lot, 
 
Best,
Priscille
 
 
 
On Sun, Apr 2, 2017 at 3:07 PM, Steve Pieper <[hidden email]> wrote:
Hi Priscille -  
 
Unfortunately it's not possible to mix the python packages between Slicer binary downloads and anaconda.  Folks have been looking at it for a while [1].
 
One option is to run the tensorflow code in another process, or even in a docker image [2] so that you can use any dependencies independent of Slicer's python constraints.
 
Hope that helps,
Steve
 
 
 
On Mon, Mar 27, 2017 at 7:25 PM, Priscille Guerrier de Dumast <[hidden email]> wrote:
Hi all,  
 
 
I am actually working on a project using TensorFlow and I would like to include that library into Slicer, as I developed an extension for it. 
For my preliminary tests, I was able to compile Slicer against an Anaconda environment, which contains TensorFlow, python2.7 and uses an independent Numpy. 
 
Now, I would like to deploy my extension. I wanted to try first on a nightly or custom version of Slicer. 
I installed pip into Slicer and I used it to install TensorFlow and its dependencies. That worked, and I was able to import TensorFlow from the Slicer Python interactor. 
Then, I added the path to my extension in Slicer and when it restarted, the following error appeared: 
 
 
>>> Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/Classification.py", line 12, in <module>
import neuralNetwork as nn
File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>
import tensorflow as tf
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 118, in <module>
from tensorflow.python.platform import app
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 23, in <module>
from tensorflow.python.platform import flags
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 25, in <module>
_global_parser = _argparse.ArgumentParser()
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/argparse.py", line 1586, in __init__
prog = _os.path.basename(_sys.argv[0])
AttributeError: 'module' object has no attribute 'argv'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/prisgdd/Desktop/work/Slicer-Extensions/ShapeClassification/src/Classification/neuralNetwork.py", line 7, in <module>
import tensorflow as tf
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/prisgdd/Applications/Slicer/installed/Slicer-nightly.app/Contents/lib/Python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
 
 
Failed to load the native TensorFlow runtime.
 
 
From what I found on Google, this error usually appears when you import TensorFlow from the folder you downloaded it, but in my case that makes no sense because I installed it into Slicer from the Slicer Python interactor.
 
Do you have any idea?
 
 
Best, 
 
Priscille de Dumast
University of Michigan
 
 
 
 
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
 
 
 
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Loading...