如何在 Windows 上配置 theano?

     2023-03-16     145

关键词:

【中文标题】如何在 Windows 上配置 theano?【英文标题】:How configure theano on Windows? 【发布时间】:2015-03-16 16:28:38 【问题描述】:

我已经在 Windows 机器上安装了 Theano,并按照配置 instructions。

我将以下 .theanorc.txt 文件放在 C:\Users\my_username 文件夹中:

#!sh
[global]
device = gpu
floatX = float32

[nvcc]
fastmath = True
# flags=-m32 # we have this hard coded for now

[blas]
ldflags =
# ldflags = -lopenblas # placeholder for openblas support

我尝试运行测试,但未能在 GPU 上运行它。我猜 .theanorc.txt 中的值没有被读取,因为我添加了行 print config.device 并输出“cpu”。

下面是基本的测试脚本和输出:

from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time

print config.device


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):
    r = f()
t1 = time.time()
print 'Looping %d times took' % iters, t1 - t0, 'seconds'
print 'Result is', r
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print 'Used the cpu'
else:
    print 'Used the gpu'

输出:

pydev debugger: starting (pid: 9564)
cpu
[Elemwiseexp,no_inplace(<TensorType(float64, vector)>)]
Looping 1000 times took 10.0310001373 seconds
Result is [ 1.23178032  1.61879341  1.52278065 ...,  2.20771815  2.29967753
  1.62323285]
Used the cpu

我已经成功安装了 CUDA Toolkit,但还没有成功安装 pyCUDA。我猜 Theano 应该可以在没有安装 pyCUDA 的情况下工作。

如果有人能帮助解决这个问题,我将不胜感激。我已按照these 的说明进行操作,但不知道为什么程序中的配置值与 .theanorc.txt 文件中的值不匹配。

【问题讨论】:

How do I install theano in Anaconda ver. 2.1 Windows 64 bit for Python 3.4?的可能重复 【参考方案1】:

Theano 不需要 PyCUDA 是对的。

奇怪的是 Theano 没有读取你的配置文件。被读取的确切路径是这样的。只需在 Python 中运行它,您就会看到它的放置位置:

os.path.expanduser('~/.theanorc.txt')

【讨论】:

上述命令的输出是'C:\\Users\\niko/.theanorc.txt' 您使用哪个版本的 Theano?您应该使用开发版本而不是最后一个版本:deeplearning.net/software/theano/…【参考方案2】:

尝试按照 Theano 网站 (http://deeplearning.net/software/theano/install_windows.html) 的指示更改 .theanorc.txt 中的内容。路径需要根据您的安装进行相应更改。

[global]
floatX = float32
device = gpu

[nvcc]
flags=-LC:\Users\cchan\Anaconda3\libs
compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin

【讨论】:

【参考方案3】:

与几页上所说的相反,我的安装(Windows 10、Python 2.7、Theano 0.10.0.dev1)不会解释我的用户配置文件文件夹中 .theanorc.txt 文件中的配置指令,但会读取.theanorc 文件。

如果您在创建具有该名称样式的文件时遇到问题,请在终端上使用以下命令:

cd %USERPROFILE%
type NUL > .theanorc

酱:http://ankivil.com/making-theano-faster-with-cudnn-and-cnmem-on-windows-10/

【讨论】:

感谢您的解决方案...你救了我:)

在 Windows 7 上导入 Theano 时出现 g++ 错误

】在Windows7上导入Theano时出现g++错误【英文标题】:g++erroronimportofTheanoonWindows7【发布时间】:2016-11-2623:13:47【问题描述】:我正在尝试根据thetheanoinstallationguide使用正确的g++安装进行设置。我以前让theano使用仅python的实现。我在p... 查看详情

TensorFlow 1.0 在 Windows 上看不到 GPU(但 Theano 有)

】TensorFlow1.0在Windows上看不到GPU(但Theano有)【英文标题】:TensorFlow1.0doesnotseeGPUonWindows(butTheanodoes)【发布时间】:2017-07-1707:36:13【问题描述】:我在Windows上运行了Keras和Theano安装(通过关注tutorial)。现在我尝试将后端切换到Ten... 查看详情

如何在 Windows 上的 Anaconda Python 中安装 Keras 和 Theano?

】如何在Windows上的AnacondaPython中安装Keras和Theano?【英文标题】:HowdoIinstallKerasandTheanoinAnacondaPythononWindows?【发布时间】:2016-03-0922:55:47【问题描述】:我正在尝试使用以下Keras包在Python中处理神经网络:fromkeras.utilsimportnp_utilsfrom... 查看详情

如何在 GPU 上运行 theano

】如何在GPU上运行theano【英文标题】:HowcanIruntheanoonGPU【发布时间】:2016-02-0418:57:16【问题描述】:如果我使用python3.5运行以下代码importnumpyasnpimporttimeimporttheanoA=np.random.rand(1000,10000).astype(theano.config.floatX)B=np.random.rand(10000,1000).a 查看详情

windows下pycharm使用theano的方法

  安装theano前需要自行安装Anaconda和PyCharm。在网上查了在PyCharm上安装theano的方法,但是均遇到了一些问题,现将问题与解决方案介绍如下。(一)第一种安装方式  打开cmd命令窗口或者Anaconda命令窗口,输入 pipinstallthean... 查看详情

如何在 ubuntu20 上以 theano 为后端的 termux 运行 keras

】如何在ubuntu20上以theano为后端的termux运行keras【英文标题】:Howtorunkerasonubuntu20ontermuxwithbackendastheano【发布时间】:2021-09-0923:22:40【问题描述】:我尝试在Pydroid3(Android)上安装theano和keras,我成功了,但是在运行keras时,theano不是... 查看详情

Theano安装,nvcc不在路径中

...已经使用他们的指南http://deeplearning.net/software/theano/install_windows.html在winpython上的windows7,64bit上安装了theano,我认为它可以工作,因为当我运行他们的第一 查看详情

Windows 上的 Theano + Cuda 8.0 - 编译错误

】Windows上的Theano+Cuda8.0-编译错误【英文标题】:Theano+Cuda8.0onWindows-CompileErrors【发布时间】:2016-06-1622:02:03【问题描述】:我让Theano在Windows10没有GPU支持的情况下正常工作。我有一个新的GTX1080,想在上面运行Theano。这需要来自NVI... 查看详情

windows安装theano

...装成功。我的电脑配置为win732bit1,下载Anaconda2-4.3.0-Windows-x86.exe(fo 查看详情

如何在 Windows 上配置 RabbitMQ 集群

】如何在Windows上配置RabbitMQ集群【英文标题】:HowtoconfigureRabbitMQClusteronWindows【发布时间】:2019-04-0218:07:51【问题描述】:拜托,我需要你的帮助。自从上周尝试在Windows服务器上配置RabbitMQ集群以来,我一直在苦苦挣扎。我重新... 查看详情

windows安装theano

...装成功。我的电脑配置为win732bit1,下载Anaconda2-4.3.0-Windows-x86.exe(for32bit)    网址https://www.continuum.io/downloads2,使用默认安装,路径在C:\\ProgramData\\Anaconda23,打开AnacondaPrompt,    输入condaupgradeconda... 查看详情

python学习笔记windows下安装theano

...:不论是实验室的电脑还是我的笔记本,只要是windows下,theano.test()都是不通过的。虽然能使用一些theano中的函数,但是我感觉很不好。所以还是转Ubuntu了……不要在这种地方瞎折腾了。———————————... 查看详情

如何在 NGINX (Windows) 上配置 PhpMyAdmin

】如何在NGINX(Windows)上配置PhpMyAdmin【英文标题】:HowtoconfigurePhpMyAdminonNGINX(Windows)【发布时间】:2013-07-2417:25:19【问题描述】:今天我开始用NGINX做一个服务器,我设法设置了PHP和MySQL,一切都很顺利。但是,我需要NGINX打开PhpMyAdm... 查看详情

如何在 theano 中保存/序列化经过训练的模型?

】如何在theano中保存/序列化经过训练的模型?【英文标题】:Howtosave/serializeatrainedmodelintheano?【发布时间】:2015-08-1013:38:47【问题描述】:我将模型保存在loadingandsaving上。#savingtrainedmodelf=file(\'models/simple_model.save\',\'wb\')cPickle.dump... 查看详情

如何在 Windows 上配置用户特定的主机文件 [关闭]

】如何在Windows上配置用户特定的主机文件[关闭]【英文标题】:HowtoconfigureuserspecifichostsfileonWindows[closed]【发布时间】:2012-05-0520:01:51【问题描述】:有许多用户可以访问的WindowsServer2003机器。他们每个人都想配置自己的主机文件... 查看详情

python学习笔记windows下安装theano

...:不论是实验室的电脑还是我的笔记本,只要是windows下,theano.test()都是不通过的。虽然能使用一些theano中的函数,但是我感觉很不好。所以还是转Ubuntu了……不要在这种地方瞎折腾了。———————————... 查看详情

Theano 在树莓派上使用 Keras

】Theano在树莓派上使用Keras【英文标题】:TheanowithKerasonRaspberryPi【发布时间】:2017-03-1201:32:27【问题描述】:我试图让Theano在RaspberryPi3(B)上与Keras一起运行,但没有成功。我尝试将UbuntuMATE和Raspbian作为操作系统,但没有成功。为... 查看详情

python在gpu上测试theano(代码片段)

查看详情