小编use*_*652的帖子

如何在Ipython Notebook上使用我的GPU?

操作系统:Ubuntu 14.04LTS
语言:Python Anaconda 2.7(keras,theano)
GPU:GTX980Ti CUDA:CUDA 7.5

我想通过使用我的GPU(GTX980Ti)在IPython Notebook上运行keras python代码
但是我找不到它.

我想测试下面的代码.当我把它运行到Ubuntu终端时,我命令如下(它使用GPU很好.它没有任何问题)

首先,我设置如下的路径

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH 
Run Code Online (Sandbox Code Playgroud)

其次,我运行如下代码

THEANO_FLAGS='floatX=float32,device=gpu0,nvcc.fastmath=True'  python myscript.py
Run Code Online (Sandbox Code Playgroud)


它运行良好.

但是当我在pycharm(python IDE)上运行代码或者当我在Ipython Notebook上运行它时,它不使用gpu.它只使用CPU

myscript.py代码如下.

from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time
vlen = 10 * 30 * 768  # 10 x #cores x # threads per core
iters = 1000
rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in xrange(iters): …
Run Code Online (Sandbox Code Playgroud)

ipython nvcc theano keras

7
推荐指数
1
解决办法
8605
查看次数

"RuntimeError:从不同的公寓调用Tcl"tkinter和threading

我想使用线程和tkinter(python 3.6)实现GUI .
当我运行GUIExecution.py时,会发生以下错误.在base_gui_class.py中的self.root.mainloop()上运行
" RuntimeError:从不同的appartment调用Tcl "
我在类的基础上实现它,三个代码文件如下所示.
可执行文件是GUIExecution.py.我花了很多时间来修复错误,但我还没能解决它.
请提出很多建议.
另外,如果我在python2环境中运行以下代码,它可以正常工作而不会出错.

GUIExecution.py

from base_gui_class import *

from base_class import *

speed = 1000
height = 500
width = 700

base_model = base_class()
gui = base_gui_class(base_model, speed, height, width)
base_model.visualize()
Run Code Online (Sandbox Code Playgroud)

base_class.py

class base_class():
    genes = []
    dicLocations = {}
    gui = ''
    best = ''
    time = 0

    def __init__(self):
        pass

    def visualize(self):
        if self.gui != '':
            self.gui.start()

    def registerGUI(self, gui):
        self.gui = gui
Run Code Online (Sandbox Code Playgroud)

base_gui_class.py

import threading
import tkinter …
Run Code Online (Sandbox Code Playgroud)

multithreading tkinter tcl python-3.x

5
推荐指数
1
解决办法
4707
查看次数

为什么在Windows C编程中获得“ a.exe”而不是“ a.out”

当我通过cc hello_world.c在“ hello_world.c”下面进行编译时,
它将生成一个“ a.exe”而不是“ a.out”

#include <stdio.h>

main()
{
    printf("hello, world\n");
}
Run Code Online (Sandbox Code Playgroud)
  1. “ a.out”和“ a.exe”有什么区别?
  2. 为什么我得到的是“ a.exe”而不是“ a.out”?

c compilation

0
推荐指数
1
解决办法
1305
查看次数

标签 统计

c ×1

compilation ×1

ipython ×1

keras ×1

multithreading ×1

nvcc ×1

python-3.x ×1

tcl ×1

theano ×1

tkinter ×1