anaconda 安装theano的万能指令!!(vscode下安装成功)

我很感动

经历了一堆安装theano的挫折

安装theano

步骤:

1. 在anaconda的的anaconda prompt下进入你的安装环境,输入以下指令:

conda install numpy scipy mkl-service libpython m2w64-toolchain

 这里另外说一下网上基本上遍布的安装theano方法:

使用

conda install mingw libpython

来安装mingw,但我想说这种方法安装的mingw是32位的,所以如果使用这种方法来安装,运行theano的时候会出现错误

 

下面还有一小段错误~忘截图了,大概意思是can"t compile 64bit?...反正就是说编译不了64位

所以这就要求你需要安装64位的mingw,第一条指令可以解决这个问题。

2.安装theano

pip install theano

3. 添加环境变量path

添加:

怎么添加环境变量就不说了,网上很多教程。

4.编写一个txt

在C:/users/dell目录下添加一个txt

在txt文件里加入以下内容:

-I后面加的是mingw的安装目录

经历这些步骤,theano差不多就算安装完了,可以测试一下:

import numpy

import theano.tensor as T

import sys

from theano import function

x = T.dscalar('x')

y = T.dscalar('y')

z = x + y

f = function([x, y], z)

print f(2,3)

# print theano.__path__

# print sys.path

出来5就算对了

对vscode的配置

点击python

选第三个,configure python language based settings

修改user settings

修改python.pythonpath

theano gpu

gpu测试

from theano import function, config, shared, tensor

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([], tensor.exp(x))

print(f.maker.fgraph.toposort())

t0 = time.time()

for i in range(iters):

r = f()

t1 = time.time()

print("Looping %d times took %f seconds" % (iters, t1 - t0))

print("Result is %s" % (r,))

if numpy.any([isinstance(x.op, tensor.Elemwise) and

('Gpu' not in type(x.op).__name__)

for x in f.maker.fgraph.toposort()]):

print('Used the cpu')

else:

print('Used the gpu')

 

 

 

 

 

 

 

 

 

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值