简体   繁体   English

AWS EC2 Python ModuleNotFoundError

[英]AWS EC2 Python ModuleNotFoundError

I am using an EC2 instance with Deep Learning AMI based on Ubuntu 18.04.我正在使用具有基于 Ubuntu 18.04 的深度学习 AMI 的 EC2 实例。

I am doing the following:我正在执行以下操作:

  • Start the terminal启动终端
  • Activate the conda environment: conda activate tensorflow2_latest_p37激活 conda 环境: conda activate tensorflow2_latest_p37
  • Install the package pip3 install tensorrt安装package pip3 install tensorrt
  • Run my code python3 mycode.py运行我的代码python3 mycode.py

And I get the following error:我收到以下错误:

ModuleNotFoundError: No module named 'tensorrt'

I also trying to install as sudo or with -U or -m option.我也尝试安装为sudo或使用-U-m选项。 Nothing work.没有任何工作。 I can't install with conda install because tensorrt is not available in it.我无法使用 conda install 安装,因为 tensorrt 在其中不可用。

pip3 will use ubuntu's level pip3, not from anaconda. pip3将使用 ubuntu 的级别 pip3,而不是来自 anaconda。 You can confirm this by using which pip3 after you activate your environemnt.您可以在激活环境后使用which pip3来确认这一点。 ALso tensorrt is not available for python other then 3.6 tensorrt 不适用于 python 3.6 以外的版本

So to install tensorrt on Ubuntu 18.04 Deep Learnig:所以要在 Ubuntu 18.04 深度学习上安装tensorrt

conda activate tensorflow2_p36

# then in tensorflow2_p36 environment

pip install nvidia-pyindex
pip install --upgrade nvidia-tensorrt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM