Issue exiting code
Hello folks!
I am running a python code with tensorflow (installed with pip install tensorflow-gpu, nvidia drivers and cuda are compatible and work, Ubuntu 16.04) and at the end of the execution I run into the following problem:
Traceback (most recent call last):
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/pydevconsole.py", line 221, in do_exit
import java.lang.System
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named 'java'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/code.py", line 91, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/dalsasso/sarcnn/main.py", line 96, in <module>
tf.app.run()
File "/home/dalsasso/.local/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
Note that the program runs fine, it just isn't ending properly and I have to press the stop button to end the the program.
Please note that when running the same code from a terminal with the same setup as the venv used in pycharm I don't experience any problem and it works just fine.
Please sign in to leave a comment.
Hi Emanuele,
Is it possible to provide a sample project or the relevant part of it for reproducing? You can just upload it to https://uploads.services.jetbrains.com/ zipped and let me know the name of that file.
Hi Sergey,
It is providing me the same error even when executing the following simple code:
And the following is the output:
2019-01-14 13:18:53.895270: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA
2019-01-14 13:18:53.989652: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties:
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.7335
pciBusID: 0000:65:00.0
totalMemory: 7.92GiB freeMemory: 265.69MiB
2019-01-14 13:18:53.989674: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2019-01-14 13:18:54.210535: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-01-14 13:18:54.210564: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988] 0
2019-01-14 13:18:54.210569: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0: N
2019-01-14 13:18:54.210687: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 201 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080, pci bus id: 0000:65:00.0, compute capability: 6.1)
2019-01-14 13:18:54.218435: E tensorflow/stream_executor/cuda/cuda_driver.cc:806] failed to allocate 201.69M (211484672 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY: out of memory
30
Traceback (most recent call last):
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/pydevconsole.py", line 221, in do_exit
import java.lang.System
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named 'java'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/code.py", line 91, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/dalsasso/sarcnn/main.py", line 111, in <module>
tf.app.run()
File "/home/dalsasso/.local/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "/home/dalsasso/Software/pycharm-2018.3.2/helpers/pydev/pydevconsole.py", line 226, in do_exit
os._exit(args[0])
TypeError: an integer is required (got type NoneType)
So the code runs fine and does what it is programmed to do (i.e. print the output that is 30), the process isn't ending properly though.
Thanks for the sample code!
Hm, I am not able to reproduce it.
Does it also happen if you run it from the system terminal (outside of PyCharm) using the same interpreter?
No, it does not happen when running from terminal by using the same interpreter (I have run it from the terminal inside pycharm, so that to be sure of using the same venv, and I have specified the same interpreter).
Could it be a problem related to cuda/nvidia installation? I guess not, otherwise I would have troubles when running it from the terminal.
Indeed, if in run/debug configurations, under execution I select "emulate terminal in output console" instead of "run with Python console" I don't have any issue.
I am able to reproduce it with Run with Python console checked. It seems to be similar to https://youtrack.jetbrains.com/issue/PY-27662, please vote for it and follow for updates.
See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.
Thanks, I'm following updates on the topic!
This could be resolved by adding a return(0) at the end of the main(_).
Hi
I getting the same error anyone found a solution ? It's work when I running it via terminal, using python 3.5 in virtual env.
Any suggestions ?
Thanks in advance.