我正在运行以下fabric命令:
fab -f fabfile_awsgpu.py -R mygpu ssh
fab -f fabfile_awsgpu.py -R mygpu cuda_setup8 anaconda_setup tf_setup keras_setup torch_preroll torch_setup_solo
第一个命令打印正确的env.host_string
,而第二个命令打印env.host_string
为None
,并显示以下消息:
No hosts found. Please specify (single) host string for connection:
这是否会发生? fabfile_awsgpu如下:
env.roledefs.update(get_target_instance())
#env.hosts = ['ec2-35-167-153-191.us-west-2.compute.amazonaws.com']
#env.disable_known_hosts = True
@task
def launch():
ec2 = boto3.resource('ec2', region_name=AWS_REGION)
BlockDeviceMappings=[
{
'DeviceName': '/dev/xvda',
'Ebs': {
'VolumeSize': 600,
'DeleteOnTermination': True,
'VolumeType': 'standard',
'SnapshotId' : 'snap-c87f35ec'
},
},
]
instances = ec2.create_instances(ImageId=tgt_ami, MinCount=1, MaxCount=1,
KeyName=my_aws_key, InstanceType=INSTANCE_TYPE,
BlockDeviceMappings = BlockDeviceMappings,
EbsOptimized=True
)
inst = instances[0]
print inst
inst.wait_until_running()
inst.reload()
inst.create_tags(
Resources=[
inst.instance_id
],
Tags=[
{
'Key': 'Name',
'Value': instance_name
},
]
)
@task
def ssh():
print env.host_string
local("ssh -A " + env.host_string)
@task
def tensorboard():
local("open http://"+env.host_string+":6006")
@task
def copy_model():
local("scp " + env.host_string+":/tmp/model.ckpt /tmp/")
@task
def basic_setup():
print env.host_string
print env.hosts
run("sudo yum update -q -y")
run("sudo yum groupinstall 'Development Tools' -q -y")
run("sudo yum install -q -y emacs tmux gcc g++ dstat htop")
run("sudo yum install -y kernel-devel-`uname -r`")