【问题标题】:After tensorflow operation, ipython console changes back to in [1]tensorflow运行后,ipython控制台变回[1]
【发布时间】:2025-12-03 22:30:02
【问题描述】:

编辑器:Spyder(Python 3.7)

张量流:v1.10.0

问题: 当我运行单元格时,Ipython 控制台会变回 [ 1 ] 中。 并且不打印任何消息。 也没有错误信息。

tf.reset_default_graph()
with tf.Session() as sess:
    np.random.seed(1)
    X, Y = create_placeholders(64, 64, 3, 6)
    parameters = initialize_parameters()
    Z3 = forward_propagation(X, parameters)
    init = tf.global_variables_initializer()
    sess.run(init)
    a = sess.run(Z3, {X: np.random.randn(2,64,64,3), Y: np.random.randn(2,6)})
    print("Z3 = " + str(a))
2020-04-14 21:58:13.731852: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0
2020-04-14 21:58:13.731877: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-04-14 21:58:13.731881: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971]      0 
2020-04-14 21:58:13.731884: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0:   N 
2020-04-14 21:58:13.731927: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4859 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2060, pci bus id: 0000:01:00.0, compute capability: 7.5)

但在运行此单元之前。它工作正常

tf.reset_default_graph()
with tf.Session() as sess_test:
    parameters = initialize_parameters()
    init = tf.global_variables_initializer()
    sess_test.run(init)
    print("W1 = " + str(parameters["W1"].eval()[1,1,1]))
    print("W2 = " + str(parameters["W2"].eval()[1,1,1]))
2020-04-14 21:57:56.449259: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2020-04-14 21:57:56.533637: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:897] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-04-14 21:57:56.533818: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 0 with properties: 
name: GeForce RTX 2060 major: 7 minor: 5 memoryClockRate(GHz): 1.71
pciBusID: 0000:01:00.0
totalMemory: 5.79GiB freeMemory: 5.12GiB
2020-04-14 21:57:56.533829: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0
2020-04-14 21:57:56.681264: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-04-14 21:57:56.681288: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971]      0 
2020-04-14 21:57:56.681292: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0:   N 
2020-04-14 21:57:56.681345: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4859 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2060, pci bus id: 0000:01:00.0, compute capability: 7.5)

我得到了正确的打印信息。

谁能帮帮我?谢谢

【问题讨论】:

  • 请不要将重要信息发布为图片。未来的访问者无法搜索它们
  • 好的,我改一下。

标签: python tensorflow gpu


【解决方案1】:

我把tensorflow版本升级到1.14.0就可以了

 conda install tensorflow==1.14.0

【讨论】: