# Remote-exec on aws: . activate pytorch\_p36 doesn\`t apply from terraform plan, but interactivelly is ok

**URL:** <https://discuss.hashicorp.com/t/remote-exec-on-aws-activate-pytorch-p36-doesn-t-apply-from-terraform-plan-but-interactivelly-is-ok/3393>\
**Category:** Terraform\
**Created:** [October 17, 2019, 8:35am UTC](https://discuss.hashicorp.com/t/remote-exec-on-aws-activate-pytorch-p36-doesn-t-apply-from-terraform-plan-but-interactivelly-is-ok/3393 "2019-10-17T08:35:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxrodkin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxrodkin/32/2714_2.png) [@maxrodkin](https://discuss.hashicorp.com/u/maxrodkin)\
**Post date:** [October 17, 2019, 8:35am UTC](https://discuss.hashicorp.com/t/remote-exec-on-aws-activate-pytorch-p36-doesn-t-apply-from-terraform-plan-but-interactivelly-is-ok/3393/1 "2019-10-17T08:35:36Z")

</div>

Hi, i ran:  
Instance type: g2.2xlarge  
AMI ID: Deep Learning AMI (Ubuntu 16.04) Version 24.3 (ami-008349d4902badfc6)  
main.tf section:  
provisioner “remote-exec” {  
inline = [  
“nvidia-smi”,  
“. activate pytorch\_p36”,  
“python -c “import torch; print(torch.cuda.is\_available())””,  
]  
}  
The log:  
aws\_spot\_instance\_request.web (remote-exec): Connected!  
aws\_spot\_instance\_request.web (remote-exec): Thu Oct 17 08:17:16 2019  
aws\_spot\_instance\_request.web (remote-exec): ±----------------------------------------------------------------------------+  
aws\_spot\_instance\_request.web (remote-exec): | NVIDIA-SMI 418.87.00 Driver Version: 418.87.00 CUDA Version: 10.1 |  
aws\_spot\_instance\_request.web (remote-exec): |-------------------------------±---------------------±---------------------+  
aws\_spot\_instance\_request.web (remote-exec): | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |  
aws\_spot\_instance\_request.web (remote-exec): | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |  
aws\_spot\_instance\_request.web (remote-exec): |===============================+======================+======================|  
aws\_spot\_instance\_request.web (remote-exec): | 0 GRID K520 On | 00000000:00:03.0 Off | N/A |  
aws\_spot\_instance\_request.web (remote-exec): | N/A 33C P0 44W / 125W | 0MiB / 4037MiB | 0% Default |  
aws\_spot\_instance\_request.web (remote-exec): ±------------------------------±---------------------±---------------------+

aws\_spot\_instance\_request.web (remote-exec): ±----------------------------------------------------------------------------+  
aws\_spot\_instance\_request.web (remote-exec): | Processes: GPU Memory |  
aws\_spot\_instance\_request.web (remote-exec): | GPU PID Type Process name Usage |  
aws\_spot\_instance\_request.web (remote-exec): |=============================================================================|  
aws\_spot\_instance\_request.web (remote-exec): | No running processes found |  
aws\_spot\_instance\_request.web (remote-exec): ±----------------------------------------------------------------------------+  
aws\_spot\_instance\_request.web: Still creating… [1m0s elapsed]  
aws\_spot\_instance\_request.web (remote-exec): Traceback (most recent call last):  
aws\_spot\_instance\_request.web (remote-exec): File “”, line 1, in   
aws\_spot\_instance\_request.web (remote-exec): ModuleNotFoundError: No module named ‘torch’  
i.e. envoirement doesn`t activated. But, then i ssh`ed to instance manually, it ran:  
ubuntu@ip-172-31-29-152:~ . activate pytorch\_p36 NOTE that the Amazon EC2 g2 instance type is no longer supported by the Deep Learning AMI. Please review the DLAMI EC2 instance selection guide for supported Amazon EC2 instance types. (pytorch\_p36) ubuntu@ip-172-31-29-152:~ python -c “import torch; print(torch.cuda.is\_available())”  
True

What`s problem with remote-exec ?

---

<div class="post-metadata">

**Author:** ![maxrodkin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxrodkin/32/2714_2.png) [@maxrodkin](https://discuss.hashicorp.com/u/maxrodkin)\
**Post date:** [October 17, 2019, 12:48pm UTC](https://discuss.hashicorp.com/t/remote-exec-on-aws-activate-pytorch-p36-doesn-t-apply-from-terraform-plan-but-interactivelly-is-ok/3393/2 "2019-10-17T12:48:45Z")

</div>

the problem is: terraform has construct sh script(not bash) from inline = […] section and has sending to EC2 instance to run. So, bash commands cannot running in inline section. Forget it.  
Use  
provisioner “file” {  
source = “script.sh”  
destination = “/tmp/script.sh”  
}

```
  provisioner "remote-exec" {
    inline = [
      "chmod +x /tmp/script.sh",
      "/tmp/script.sh",

```

instead.
