Jesus M.
Jesus M.

Reputation: 23

Python file works in Pycharm but not in termial

I am running a python file in pycharm and there is no problem, but when I want to run it in the terminal, I get the error: tensorflow.python.framework.errors_impl.InternalError: CUDA runtime implicit initialization on GPU:0 failed. Status: out of memory

Why does the same script work in pycharm but not in the terminal?

Upvotes: 0

Views: 117

Answers (2)

Jesus M.
Jesus M.

Reputation: 23

I managed to solve the problem, for everyone who have the same problem, I add at the beggining:

import os
os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'
import tensorflow as tf
physical_devices = tf.config.list_physical_devices('GPU')
for device in physical_devices:
    tf.config.experimental.set_memory_growth(device, True)

And now it works perfectly

Upvotes: 0

SuhailHasan
SuhailHasan

Reputation: 50

Actually it works on pycharm is the same as it works on terminal, what I mean is, pycharm indirectly uses their inbuilt terminal as I've noticed, so my guess is that you might have a module error, because all the modules you install in pycharm are just stored in a virtual environment, and not in the actual environment.

Upvotes: 1

Related Questions