Mac Setup Specifics

Dear All

Setting up a thread to put in any Mac specific things that is needed when you do the course on a Mac machine. The first thing that I want to notify is when I wanted to copy the aws scripts into my bash on my home folder in Mac it was not .bashrc. The following steps are needed to do this on Mac

  • Pls add scripts from setup folder to your root folder on Mac
  • In your bash_profile on root or home folder add “source aws-alias.sh” in the last line
  • Now you don’t have to run source aws-alias.sh as such every time. You can straight away run it from the prompt with alias or aws-get-p2 or any of those commands

Hope this helps.

Hey thanks for the tip. Which script files do I need in my root folder? All of them in the setup folder?

Hi mjay

Welcome to the deep learning course. I am having a lot of fun learning this and I hope you do too. In my case I only copied in the source aws-alias.sh. But you could go ahead and copy all of them in the root folder. Mainly go to your bash_profile in your root folder to add “source aws-alias.sh” in the last line.

Regards
Vijay

Thanks for the response.

This is what I see if I type in “vim .bashprofile”. Is it right to add “source aws-alias.sh” after $reset?

added by Anaconda2 4.2.0 installer

export PATH="/Users/KimMinjun/anaconda/bin:$PATH"

added by Anaconda3 4.3.1 installer

export PATH="/Applications/anaconda/bin:$PATH"

Enable tab completion

source ~/.udacity-terminal-config/git-completion.bash

Change command prompt

source ~/.udacity-terminal-config/git-prompt.sh

colors!

red="[\033[38;5;203m]“
green=”[\033[38;05;38m]“
blue=”[\033[0;34m]“
reset=”[\033[0m]"

export GIT_PS1_SHOWDIRTYSTATE=1

‘\u’ adds the name of the current user to the prompt

‘$(__git_ps1)’ adds git-related stuff

‘\W’ adds the name of the current directory

export PS1="$red\u$green$(__git_ps1)$blue \W
$ $reset"

Pls use the “bash_profile” file in your root and not bashprofile. Hope this helps.

oh, it was just a typo. i did use bash_profile. adding source aws-alias.sh to this doesn’t work.

What do you exactly mean by ‘root folder’? Where I am now is /Users/MyName… is this right?

Yes /Users/MyName is the root folder. And you can add it to the file after your “reset”. Please check if it is working if you do source aws-alias.sh from your terminal directly. In my case it worked very well. But I added the same to bash_history after I set up the AWS using the setup-p2.sh. Is your aws t2 setup already?

I meant AWS P2.

Yes, it all worked…

Oh, now it works! Thanks.

I guess my problem was that I’ve put source aws-alias.sh before the last "

And now as i’ve just put it after ", it works.

Thank you so much!

Good to know that it worked well! :slight_smile:

Hi Vijay, thank for your post. I don’t seem to have a “bash_profile” in my root folder. I am trying to run the “aws-alias.sh” from “Users/XX/Downloads” but is not working (though setup_p2.sh did work). Thank you!

@jbpartarrieu Pls try to run source aws-alias.sh from “Users/XX/Downloads”. Then try to run commands like aws-start etc and see if it works.

Thank you, nothing happens. It’s as if the script is not running properly. I created one in Xcode as the one in Github couldn’t be used with wget.
I did add a line to the “bash_profile” that is sitting in the root folder.
This is the aws-alias.sh script that I have, it’s very weird:

alias aws-get-p2='export instanceId=aws ec2 describe-instances --filters "Name=instance-state-name,Values=stopped,Name=instance-type,Values=p2.xlarge" --query "Reservations[0].Instances[0].InstanceId" && echo $instanceId’
alias aws-get-t2='export instanceId=aws ec2 describe-instances --filters "Name=instance-state-name,Values=stopped,Name=instance-type,Values=t2.xlarge" --query "Reservations[0].Instances[0].InstanceId" && echo $instanceId’
alias aws-start='aws ec2 start-instances --instance-ids $instanceId && aws ec2 wait instance-running --instance-ids $instanceId && export instanceIp=aws ec2 describe-instances --filters "Name=instance-id,Values=$instanceId" --query "Reservations[0].Instances[0].PublicIpAddress" && echo $instanceIp’
alias aws-ip='export instanceIp=aws ec2 describe-instances --filters "Name=instance-id,Values=$instanceId" --query "Reservations[0].Instances[0].PublicIpAddress" && echo $instanceIp’
alias aws-ssh='ssh -i ~/.ssh/aws-key-fast-ai.pem ubuntu@$instanceIp’
alias aws-stop='aws ec2 stop-instances --instance-ids $instanceId’
alias aws-state=‘aws ec2 describe-instances --instance-ids $instanceId --query “Reservations[0].Instances[0].State.Name”’

if [[ uname == “CYGWIN” ]]
then

This is cygwin. Use cygstart to open the notebook

alias aws-nb='cygstart http://:8888$instanceIp
fi

if [[ uname == “Linux” ]]
then

This is linux. Use xdg-open to open the notebook

alias aws-nb='xdg-open http://:8888$instanceIp
fi

if [[ uname == “Darwin” ]]
then

This is Mac. Use open to open the notebook

alias aws-nb='open http://:8888$instanceIp
fi

Ok. Lets check a few things now. Have you created the AWS instance already and then using the scripts to connect to the instance that you have? Have you completed the aws config already in your terminal? Do let me know to proceed further.

Thank you!
Yes, just completed setup_p2.sh and I have an instance running.
This is what it looks like:
All done. Find all you need to connect in the fast-ai-commands.txt file and to remove the stack call fast-ai-remove.sh
Connect to your instance: ssh -i /Users/jbarrigapartarrieu/.ssh/aws-key-fast-ai.pem ubuntu@ec2-34-241-212-213.eu-west-1.compute.amazonaws.com
Jorges-MBP:~ jbarrigapartarrieu$ bash aws-alias.sh
Jorges-MBP:~ jbarrigapartarrieu$ aws-start

An error occurred (InvalidParameterCombination) when calling the StartInstances operation: No instances specified
Jorges-MBP:~ jbarrigapartarrieu$ aws-stop

An error occurred (InvalidParameterCombination) when calling the StopInstances operation: No instances specified
Jorges-MBP:~ jbarrigapartarrieu$

Pls install aws-cli in your system. You can install using

pip install awscli

. Then do

aws config

you will be asked to enter

AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]:

Pls follow the instructions in http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html.
Once done add source aws-alias.sh in your bash_profile. Then

aws-get-p2

first. If you are getting the instance id back, then all is well. Then you can start

aws-start

After that you can ssh into the instance using

aws-ssh

or

ssh -i /Users/jbarrigapartarrieu/.ssh/aws-key-fast-ai.pem ubuntu@ec2-34-241-212-213.eu-west-1.compute.amazonaws.com

Let me know how it goes.