I am trying to create a single executable file with pyinstaller, I have installed in my environment tensorflow-cpu==2.9 and tensorflow-directml-plugin==0.0.1.dev220621 I used this because I have an intel GPU where I want to run a tensorflow model. I found this solution in here. When I run the script in visual studio code it runs without a problem and the model runs in the GPU, but when I try to make it exe file with pyinstaller it gets stuck in this message:
F tensorflow/c/experimental/stream_executor/stream_executor.cc:808] Non-OK-status: stream_executor::MultiPlatformManager::RegisterPlatform( std::move(cplatform)) statum( std::move(cplatform)) status: INTERNAL: platform is already registered with name: "DML"
Also before that message, it spams a lot this:
2022-07-20 15:01:23.929010: I tensorflow/c/logging.cc:34] Successfully opened dynamic library dxgi.dll
2022-07-20 15:01:23.930664: I tensorflow/c/logging.cc:34] Successfully opened dynamic library d3d12.dll
2022-07-20 15:01:23.993556: I tensorflow/c/logging.cc:34] DirectML device enumeration: found 1 compatible adapters.
2022-07-20 15:01:26.072697: I tensorflow/c/logging.cc:34] Successfully opened dynamic library C:\Users\xx\Documents\DMLEnvironment\lib\site-packages\tensorflow-plugins/directml/directml.0de2b4431c6572ee74152a7ee0cd3fb1534e4a95.dll
I tried uninstalling tensorflow-cpu and installing the normal tensorflow, but then the script did not run. I think there is a conflict between tensorflow-cpu and tensorflow-directml-plugin but I find it weird that it works if I run the script directly from visual studio code.
Any idea of why this could be happening?
P.S. I am using virtual environment with python 3.8 and pyinstaller 5.2
Update:
I managed to make it work with Pyinstaller 4.10 and there is a problem:
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "tensorflow\__init__.py", line 37, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "tensorflow\python\__init__.py", line 37, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "tensorflow\python\eager\context.py", line 33, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "tensorflow\python\pywrap_tfe.py", line 25, in <module>
ImportError: DLL load failed while importing _pywrap_tfe: Die angegebene Prozedur wurde nicht gefunden.
[13284] Failed to execute script due to unhandled exception!
I managed to solve this problem by adding the .pyd file in my .spec file in the data option like:
datas=[
("DMLEnvironment/Lib/site-packages/tensorflow/python/_pywrap_tfe.pyd", "tensorflow/python"),
],
but the exe file (onefile) does not run the tensorflow-directml-plugin because my model is still running in the CPU and not the GPU. I tried to put tensorflow-directml-plugin package as a hidden import in the .spec file but this didn't work.
Related
I've tried using pyinstaller, py2exe and auto-py-to-exe but keep having similar problems. First, py2exe seems to be abandoned, but pyinstaller and auto-py-to-exe correctly build an exe that can run, and run the beginning of my code, however when I try to load a pickled model using joblib dump/load I get the following error. This is the same error I get when I run the python script in the wrong environment.
How can I build from the correct conda environment?
**Traceback (most recent call last):
File "test.py", line 43, in <module>
File "test.py", line 24, in main
File "site-packages\joblib\numpy_pickle.py", line 598, in load
File "site-packages\joblib\numpy_pickle.py", line 526, in _unpickle
File "pickle.py", line 1088, in load
File "pickle.py", line 1376, in load_global
File "pickle.py", line 1426, in find_class
ModuleNotFoundError: No module named 'sklearn.mixture._gaussian_mixture'
[12708] Failed to execute script test**
I want to convert Python code into standalone executable , the code uses numpy, scipy, and Pymc3 modules. I am using Python 3.6.4. I have created the project using Virtual Environment in Pycharm IDE. The command that I used to run pyinstaller is as follows:
venv/Scripts/pyinstaller --onefile src/POD.py
venv being the folder where virtual environment is stored and src being the folder where my Python source code ie. POD.py is saved. Pyinstaller runs just fine generates some warning message, but when I try to run the executable generated by pyinstaller it thrown as error
Traceback (most recent call last):
File "POD.py", line 196, in <module>
File "POD.py", line 79, in train
File "Lib\site-packages\theano\tensor\var.py", line 155, in __mul__
File "Lib\site-packages\theano\gof\op.py", line 615, in __call__
File "Lib\site-packages\theano\tensor\elemwise.py", line 482, in make_node
File "Lib\site-packages\theano\tensor\elemwise.py", line 438, in get_output_info
File "Lib\site-packages\theano\tensor\elemwise.py", line 157, in __init__
File "Lib\site-packages\theano\gof\op.py", line 1308, in __init__
File "Lib\site-packages\theano\gof\op.py", line 1331, in load_c_code
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\User\\AppData\\Local\\Temp\\_MEI126642\\theano\\tensor\\c_code\\dimshuffle.c'
[4756] Failed to execute script POD
Seems like it is trying to find the file dimshuffle.c outside of the virtual environment. In-fact the I can see that there is folder inside virtual environment which has the dim_shuffle.c code. I can find it inside virtual environment in following folder.
venv/Lib/site-packages/theano/tensor/c_code/dimshuffle,c
My question is how do I instruct pyinstaller to look for dimshuffle inside virtual environment folder?
You can,
extend the sys.path by editing the spec file.
pyi-makespec --paths=/path/to/thisdir \
--paths=/path/to/otherdir myscript.py
List the hidden imports using the spec file.
for more info refer this
I developed a project in python 3.4.1 and pyqt4. Then I converted my python program to executable file using cx_freeze module.
Everything is perfectly fine, but I found two problems here:
Size of program gets really high.
I like to assort my files in special folders by their format type, for example all of the .dll files in a folder called DLL and something like that, but when I do this I ran into some problems.
Is it really possible ? If yes give me some information and if no, what can I do to solve my problems. Thanks
Error I get :
cx_Freeze: Python error in main script
Traceback (most recent call last): File
"C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line
27, in
exec(code, m.dict) File "MY APP.py", line 1, in File "c:\Python\64-bit\3.4\lib\importlib_bootstrap.py", line 2237, in
_find_and_load File "c:\Python\64-bit\3.4\lib\importlib_bootstrap.py", line 2226, in
_find_and_load_unlocked File "c:\Python\64-bit\3.4\lib\importlib_bootstrap.py", line 1191, in
_load_unlocked File "c:\Python\64-bit\3.4\lib\importlib_bootstrap.py", line 1161, in
_load_backward_compatible File "ExtensionLoader_PyQt4_QtCore.py", line 22, in File "ExtensionLoader_PyQt4_QtCore.py", line
21, in bootstrap ImportError: No module named PyQt4.QtCore
I have written a very long IPython notebook and need to convert it to PDF for distribution. I've read this thread but the solution didn't work for me.
I've tried the following:
If I use the Print button in my browser, I have all the IPython menu
etc. showing, which I can't accept.
If I use Print Preview from the IPython menu, none of the LaTeX equations render. They are all still just LaTeX code.
If I use ipython nbconvert --to latex --post pdf myfile.ipynb I get a FileNotFoundError. Traceback follows:
[NbConvertApp] Using existing profile dir: 'C:\\Users\\blokeley\\.ipython\\profile_default'
[NbConvertApp] Converting notebook myfile.ipynb to latex
[NbConvertApp] Support files will be in myfile_files\
[NbConvertApp] Loaded template article.tplx
[NbConvertApp] Writing 72246 bytes to myfile.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running pdflatex 3 times: ['pdflatex', 'myfile.tex']
Traceback (most recent call last):
File "C:\Anaconda3\Scripts\ipython-script.py", line 5, in <module>
sys.exit(start_ipython())
File "C:\Anaconda3\lib\site-packages\IPython\__init__.py", line 120, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "C:\Anaconda3\lib\site-packages\IPython\config\application.py", line 564,
launch_instance
app.start()
File "C:\Anaconda3\lib\site-packages\IPython\terminal\ipapp.py", line 367, in start
return self.subapp.start()
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\nbconvertapp.py",
line 268, in start
self.convert_notebooks()
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\nbconvertapp.py",
line 311, in convert_notebooks
self.postprocessor(write_resultes)
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\postprocessors\base.py",
line 28, in __call__
self.postprocess(input)
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\postprocessors\pdf.py",
line 140, in postprocess
cont = self.run_latex(filename)
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\postprocessors\pdf.py",
line 104, in run_latex
self.latex_count, log_error)
File "C:\Anaconda3\lib\site-packages\IPython\nbconvert\postprocessors\pdf.py",
line 84, in run_command
p = subprocess.Popen(command, stdout=stdout, stdin=null)
File "C:\Anaconda3\lib\subprocess.py", line 858, in __init__
restore_signals, start_new_session)
File "C:\Anaconda3\lib\subprocess.py", line 1111, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev#scipy.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
c.Application.verbose_crash=True
I'm using the latest updates from Anaconda in Python 3.4 64-bit on Windows 7 Professional.
Your issue is that you do not have LaTeX installed on your computer. When subprocess tries to call pdflatex myfile.tex it therefore fails as it cannot find pdflatex.
Whilst it's true that you can create .tex files from IPython notebooks without needing LaTeX, these are just files that contain the LaTeX code. To compile them to create PDFs you need a version of LaTeX.
Installing LaTeX on Windows is not difficult, MiKTeX is one possible installation.
I freeze a script using cx_freeze (4.3.1) in python 3.4.
The script works perfectly running in IDLE. It uses tkinter, re, and reportlab to create a pdf form.
Then the following error occurrs when I run the exe.
PS C:\Python34\build\exe.win32-3.4> .\CREEPING_cx_freeze.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "CREEPING_cx_freeze.py", line 6, in <module>
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_and_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2203, in _find_and_load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
AttributeError: 'module' object has no attribute '_fix_up_module'
It looks like everything is working. Everything is created in the build folder, but the compiled executable does not work.
I tried searching for a solution but did not find any. Could somebody help me with this?
I´m using win 8 64 bits
Wrong version installed.
pip installs 64 bits but it doesn,t work.
running the 32bits version...works