Torch 安装问题

安装问题
1. 问题:
错误:~/torch/bin/luajit: symbol lookup error: ~/anaconda/lib/libreadline.so.6: undefined symbol: PC
主要原因是 anaconda 库造成的
解决:
mv anaconda anaconda_
然后再安装
并且使用torch时,保持anaconda_ 状态。如果要使用anaconda时,再mv anaconda_ anaconda

参考:
I was following the steps outlined in this post http://torch.ch/docs/getting-started.html. When I execute ./install.sh I get the following warning and error:

Installing Lua version: LUAJIT21
cmake: /home/shree/anaconda2/lib/libcurl.so.4: no version information available (required by cmake)
/usr/bin/cmake: /home/shree/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
and repetition of same warning and, followed by the error:

/home/shree/torch/install/bin/luajit: symbol lookup error: /home/shree/anaconda2/lib/libreadline.so.6: undefined symbol: PC
Installing common Lua packages
/home/shree/torch/install/bin/luajit: symbol lookup error: /home/shree/anaconda2/lib/libreadline.so.6: undefined symbol: PC
and repetition of the same.

How do I resolve this ?

Other system related info: Ubuntu 14.04 + CUDA 7.5 + Anaconda (Python2.7)
解决方法
As the conflict seems to arise from the anaconda2 folder, I issued the following commands and it seems to be working now:

mv ~/anaconda2 ~/anaconda2_tmp
curl -sk https://raw.githubusercontent.com/torch/ezinstall/master/install-luajit+torch | PREFIX=~/torch bash
And it appears to be working. Move the anaconda2 folder back after you are done.
出处:
http://askubuntu.com/questions/699864/torch7-installation-issues-on-14-04

### 验证 Torch 是否成功安装 要验证 `torch` 是否成功安装,可以通过以下几种方式来进行验证: 1. **导入 `torch` 模块并检查版本** 如果 `torch` 安装成功,可以正常导入模块并查看当前安装的版本号。在 Python 脚本或交互式环境中运行以下代码: ```python import torch print("PyTorch Version:", torch.__version__) ``` 2. **检查 CUDA 是否可用** 如果使用的是支持 GPU 的 PyTorch 版本,可以进一步检查 CUDA 是否可用,并查看当前系统中可用的 GPU 数量[^2]: ```python print("CUDA Available:", torch.cuda.is_available()) print("Number of GPUs:", torch.cuda.device_count()) ``` 3. **查看 CUDA 版本信息** 如果需要确认 PyTorch 使用的 CUDA 版本是否与系统中安装的版本匹配,可以执行以下代码来获取详细的 CUDA 版本信息[^1]: ```python print("CUDA Version in PyTorch:", torch.version.cuda) ``` 4. **执行张量操作并检查设备** 为了进一步验证 `torch` 是否能够正常运行,可以创建一个张量并将其移动到 GPU 上执行操作。以下代码展示了如何根据 CUDA 可用性选择设备并执行计算[^2]: ```python if torch.cuda.is_available(): x = torch.tensor([1.0, 2.0, 3.0]).cuda() print("Tensor on GPU:", x) else: x = torch.tensor([1.0, 2.0, 3.0]) print("Tensor on CPU:", x) y = x * 2 print("Result of operation:", y) ``` 5. **检查当前 GPU 设备名称** 如果需要确认具体使用的 GPU 型号,可以打印当前设备的名称信息,以验证是否成功识别到 GPU 设备[^2]: ```python if torch.cuda.is_available(): print("Current Device:", torch.cuda.current_device()) print("Device Name:", torch.cuda.get_device_name(0)) ``` 通过以上步骤,可以全面验证 `torch` 是否成功安装,并确保其与当前系统环境(尤其是 CUDA)的兼容性。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值