paddle paddle 运行 Fatal Python error: PyThreadState_Get: no current thread
2018-03-26 20:44
671 查看
使用paddlepaddle时运行tutorial代码:
import paddle.v2 as paddle # Initialize PaddlePaddle. paddle.init(use_gpu=False, trainer_count=1) # Configure the neural network. x = paddle.layer.data(name='x', type=paddle.data_type.dense_vector(13)) y_predict = paddle.layer.fc(input=x, size=1, act=paddle.activation.Linear()) with open('fit_a_line.tar', 'r') as f: parameters = paddle.parameters.Parameters.from_tar(f) # Infer using provided test data. probs = paddle.infer( output_layer=y_predict, parameters=parameters, input=[item for item in paddle.dataset.uci_housing.test()()]) for i in xrange(len(probs)): print 'Predicted price: ${:,.2f}'.format(probs[i][0] * 1000)
出现:
Fatal Python error: PyThreadState_Get: no current thread
是由于brew的python和anaconda的python冲突。
解决方法:
1.执行
otool -L /anaconda2/lib/python2.7/site-packages/py_paddle/_swig_paddle.so得到:
/anaconda2/lib/python2.7/site-packages/py_paddle/_swig_paddle.so
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1445.12.0)
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 58286.20.16)
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
发现并没有/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python 这个路径。
2.执行
install_name_tool -change /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python /anaconda/lib/libpython2.7.dylib /anaconda/lib/python2.7/site-packages/py_paddle/_swig_paddle.so此时运行paddlepaddle的tutorial,成功。
I0326 20:41:27.464560 3940180928 Util.cpp:166] commandline: –use_gpu=False –trainer_count=1
Cache file /Users/suiyang/.cache/paddle/dataset/uci_housing/housing.data not found, downloading https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data
[==== ]
[======== ]
[============ ]
[================ ]
[==================== ]
[========================= ]
[============================= ]
[================================= ]
[===================================== ]
[===================
1c6f3
====================== ]
[============================================= ]
[==================================================]Predicted price: 12,316.63Predictedprice:12,316.63Predictedprice:13,830.34
Predicted price: 11,499.34Predictedprice:11,499.34Predictedprice:17,395.05
Predicted price: 13,317.67Predictedprice:13,317.67Predictedprice:16,834.08
Predicted price: 16,632.04Predictedprice:16,632.04Predictedprice:15,384.20
Predicted price: 7,697.38Predictedprice:7,697.38Predictedprice:13,657.83
Predicted price: 6,329.62Predictedprice:6,329.62Predictedprice:12,153.18
Predicted price: 13,890.60Predictedprice:13,890.60Predictedprice:11,367.41
Predicted price: 13,269.13Predictedprice:13,269.13Predictedprice:14,979.35
Predicted price: 17,539.03Predictedprice:17,539.03Predictedprice:16,686.41
Predicted price: 16,810.74Predictedprice:16,810.74Predictedprice:13,620.53
Predicted price: 14,720.09Predictedprice:14,720.09Predictedprice:12,533.42
Predicted price: 15,835.49Predictedprice:15,835.49Predictedprice:16,064.76
Predicted price: 14,566.97Predictedprice:14,566.97Predictedprice:13,783.11
Predicted price: 16,211.73Predictedprice:16,211.73Predictedprice:16,362.79
Predicted price: 18,183.92Predictedprice:18,183.92Predictedprice:16,298.03
Predicted price: 16,084.58Predictedprice:16,084.58Predictedprice:14,406.07
Predicted price: 15,309.62Predictedprice:15,309.62Predictedprice:12,104.60
Predicted price: 9,865.44Predictedprice:9,865.44Predictedprice:14,116.36
Predicted price: 14,552.37Predictedprice:14,552.37Predictedprice:16,381.32
Predicted price: 16,992.90Predictedprice:16,992.90Predictedprice:16,722.93
Predicted price: 13,468.48Predictedprice:13,468.48Predictedprice:13,622.97
Predicted price: 16,512.31Predictedprice:16,512.31Predictedprice:17,004.60
Predicted price: 16,492.97Predictedprice:16,492.97Predictedprice:16,179.70
Predicted price: 15,989.17Predictedprice:15,989.17Predictedprice:17,289.17
Predicted price: 16,975.07Predictedprice:16,975.07Predictedprice:18,950.22
Predicted price: 15,513.54Predictedprice:15,513.54Predictedprice:15,652.08
Predicted price: 14,162.51Predictedprice:14,162.51Predictedprice:14,665.31
Predicted price: 16,724.47Predictedprice:16,724.47Predictedprice:17,369.51
Predicted price: 17,330.55Predictedprice:17,330.55Predictedprice:17,923.71
Predicted price: 18,018.71Predictedprice:18,018.71Predictedprice:19,392.96
Predicted price: 18,379.00Predictedprice:18,379.00Predictedprice:17,187.61
Predicted price: 14,920.71Predictedprice:14,920.71Predictedprice:15,435.08
Predicted price: 16,458.07Predictedprice:16,458.07Predictedprice:17,390.93
Predicted price: 17,520.05Predictedprice:17,520.05Predictedprice:18,763.72
Predicted price: 18,698.70Predictedprice:18,698.70Predictedprice:20,425.67
Predicted price: 15,431.77Predictedprice:15,431.77Predictedprice:14,803.56
Predicted price: 17,336.69Predictedprice:17,336.69Predictedprice:13,052.34
Predicted price: 16,874.23Predictedprice:16,874.23Predictedprice:18,547.62
Predicted price: 19,574.30Predictedprice:19,574.30Predictedprice:21,303.89
Predicted price: 22,053.60Predictedprice:22,053.60Predictedprice:18,862.40
Predicted price: 17,969.15Predictedprice:17,969.15Predictedprice:19,496.96
Predicted price: 17,676.56Predictedprice:17,676.56Predictedprice:18,699.87
Predicted price: 14,520.48Predictedprice:14,520.48Predictedprice:12,410.05
Predicted price: 9,987.12Predictedprice:9,987.12Predictedprice:15,381.11
Predicted price: 16,906.17Predictedprice:16,906.17Predictedprice:21,538.57
Predicted price: 21,566.74Predictedprice:21,566.74Predictedprice:19,905.33
Predicted price: 17,938.98Predictedprice:17,938.98Predictedprice:20,776.08
Predicted price: 21,715.28Predictedprice:21,715.28Predictedprice:20,169.60
Predicted price: 21,148.05Predictedprice:21,148.05Predictedprice:22,589.09
Predicted price: 21,913.31Predictedprice:21,913.31Predictedprice:24,388.41
Predicted price: 23,748.72Predictedprice:23,748.72Predictedprice:22,013.94
[Finished in 8.5s]
相关文章推荐
- Openwrt下安装Python3.5运行出现异常:Fatal Python error: Py_Initialize: Unable to get the locale encoding
- python运行不了 AttributeError: module object has no attribute getdefaultlocale
- Fatal Python error: PyImport_GetModuleDict: no module dictionary!
- python运行不了 AttributeError: module object has no attribute getdefaultlocale
- Python运行scrapy报错:ImportError: No module named win32api
- getCurrentSession 出现No hibernate bound to the thread
- caffe : /wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or dir
- python遇到AttributeError: 'str' object has no attribute '_getAssertEqualityFunc'问题解决过程
- fatal error: Python.h: No such file or directory
- 阿里云服务器使用问题fatal error: Python.h: No such file or directory解决
- fatal error: Python.h: No such file or directory
- Python--Cmd窗口运行Python时提示Fatal Python error: Py_Initialize: can't initialize sys standard streams LookupError: unknown encoding: cp65001
- python:TypeError: 'coo_matrix' object has no attribute '__getitem__'
- centos 安装pysqlite-2.8.3.tar.gz src/connection.h:26:20: fatal error: Python.h: No such file or direct
- python 编译错误TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'
- hibernate在使用getCurrentSession时提示no session found for current thread
- python 3安装错误 Fatal Python error: Py_Initialize: Unable to get the locale encoding
- 安装python-ldap fatal error: lber.h: No such file or directory
- 编译boost python模块遇到的错误:../../libraries/boost_1_44_0/boost/python/detail/wrap_python.hpp:75:24: fatal error: patchlevel.h: No such file or directory
- Python3.4运行报错:FileNotFountError:[Error 2]No such file or directory:'mnist_train.mat'