Add instructions to update to the latest version of this project

main
Aurélien Geron 2021-03-20 11:41:32 +13:00
parent 58f006a72d
commit ad922151b6
2 changed files with 62 additions and 6 deletions

View File

@ -3,7 +3,7 @@
## Download this repository
To install this repository and run the Jupyter notebooks on your machine, you will first need git, which you may already have. Open a terminal and type `git` to check. If you do not have git, you can download it from [git-scm.com](https://git-scm.com/).
Next, clone this repository by opening a terminal and typing the following commands:
Next, clone this repository by opening a terminal and typing the following commands (do not type the first `$` on each line, it's just a convention to show that this is a terminal prompt, not something else like Python code):
$ cd $HOME # or any other development directory you prefer
$ git clone https://github.com/ageron/handson-ml2.git
@ -12,20 +12,24 @@ Next, clone this repository by opening a terminal and typing the following comma
If you do not want to install git, you can instead download [master.zip](https://github.com/ageron/handson-ml2/archive/master.zip), unzip it, rename the resulting directory to `handson-ml2` and move it to your development directory.
## Install Anaconda
Next, you will need Python 3.6 or 3.7 and a bunch of Python libraries. The simplest way to install these is to use Anaconda, which is a great cross-platform Python distribution for scientific computing. It comes bundled with many scientific libraries, including NumPy, Pandas, Matplotlib, Scikit-Learn and much more, so it's quite a large installation. If you choose to [download and install Anaconda](https://www.anaconda.com/distribution/), just make sure to install the Python 3 version. If you prefer a lighter weight Anaconda distribution, you can [install Miniconda](https://docs.conda.io/en/latest/miniconda.html), which contains the bare minimum to run the `conda` packaging tool.
Next, you will need Python 3 and a bunch of Python libraries. The simplest way to install these is to [download and install Anaconda](https://www.anaconda.com/distribution/), which is a great cross-platform Python distribution for scientific computing. It comes bundled with many scientific libraries, including NumPy, Pandas, Matplotlib, Scikit-Learn and much more, so it's quite a large installation. If you prefer a lighter weight Anaconda distribution, you can [install Miniconda](https://docs.conda.io/en/latest/miniconda.html), which contains the bare minimum to run the `conda` packaging tool. You should install the latest version of Anaconda (or Miniconda) available.
Once Anaconda or miniconda is installed, then run the following command to update the conda packaging tool to the latest version:
During the installation on MacOSX and Linux, you will be asked whether to initialize Anaconda by running `conda init`: you should accept, as it will update your shell script to ensure that `conda` is available whenever you open a terminal. After the installation, you must close your terminal and open a new one for the changes to take effect.
During the installation on Windows, you will be asked whether you want the installer to update the `PATH` environment variable. This is not recommended as it may interfere with other software. Instead, after the installation you should open the Start Menu and launch an Anaconda Shell whenever you want to use Anaconda.
Once Anaconda (or Miniconda) is installed, run the following command to update the `conda` packaging tool to the latest version:
$ conda update -n base -c defaults conda
> **Note**: if you don't like Anaconda for some reason, then you can install Python 3 and use pip to install the required libraries manually (this is not recommended, unless you know what you are doing).
> **Note**: if you don't like Anaconda for some reason, then you can install Python 3 and use pip to install the required libraries manually (this is not recommended, unless you really know what you are doing). I recommend using Python 3.7, since some libs don't support Python 3.8 or 3.9 yet.
## Install the GPU Driver and Libraries
If you have a TensorFlow-compatible GPU card (NVidia card with Compute Capability ≥ 3.5), and you want TensorFlow to use it, then you should download the latest driver for your card from [nvidia.com](https://www.nvidia.com/Download/index.aspx?lang=en-us) and install it. You will also need NVidia's CUDA and cuDNN libraries, but the good news is that they will be installed automatically when you install the tensorflow-gpu package from Anaconda. However, if you don't use Anaconda, you will have to install them manually. If you hit any roadblock, see TensorFlow's [GPU installation instructions](https://tensorflow.org/install/gpu) for more details.
## Create the tf2 Environment
Next, make sure you're in the handson-ml2 directory and run the following command. It will create a new `conda` environment containing every library you will need to run all the notebooks (by default, the environment will be named `tf2`, but you can choose another name using the `-n` option):
## Create the `tf2` Environment
Next, make sure you're in the `handson-ml2` directory and run the following command. It will create a new `conda` environment containing every library you will need to run all the notebooks (by default, the environment will be named `tf2`, but you can choose another name using the `-n` option):
$ conda env create -f environment.yml
@ -53,3 +57,38 @@ When you're done with Jupyter, you can close it by typing Ctrl-C in the Terminal
$ cd handson-ml2
$ conda activate tf2
$ jupyter notebook
## Update This Project and its Libraries
I regularly update the notebooks to fix issues and add support for new libraries. So make sure you update this project regularly.
For this, open a terminal, and run:
$ cd $HOME # or whatever development directory you chose earlier
$ cd handson-ml2 # go to this project's directory
$ git pull
If you get an error, it's probably because you modified a notebook. In this case, before running `git pull` you will first need to commit your changes. I recommend doing this in your own branch, or else you may get conflicts:
$ git checkout -b my_branch # you can use another branch name if you want
$ git add -u
$ git commit -m "describe your changes here"
$ git checkout master
$ git pull
Next, let's update the libraries. First, let's update `conda` itself:
$ conda update -c defaults -n base conda
Then we'll delete this project's `tf2` environment:
$ conda activate base
$ conda env remove -n tf2
And recreate the environment:
$ conda env create -f environment.yml
Lastly, we reactivate the environment and start Jupyter:
$ conda activate tf2
$ jupyter notebook

View File

@ -57,5 +57,22 @@ Finally, start Jupyter:
If you need further instructions, read the [detailed installation instructions](INSTALL.md).
# FAQ
Which Python version should I use?
:I recommend Python 3.7. If you follow the installation instructions above, that's the version you will get. Most code will work with other versions of Python 3, but some libraries do not support Python 3.8 or 3.9 yet, which is why I recommend Python 3.7.
I'm getting an error when I call `load_housing_data()`.
:Make sure you call `fetch_housing_data()` *before* you call `load_housing_data()`. If you're getting an HTTP error, make sure you're running the exact same code as in the notebook (copy/paste it if needed). If the problem persists, please check your network configuration.
I'm getting an SSL error on MacOSX
:You probably need to install the SSL certificates (see this [StackOverflow question](https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error)). If you downloaded Python from the official website, then run `/Applications/Python\ 3.7/Install\ Certificates.command` in a terminal (change `3.7` to whatever version you installed). If you installed Python using MacPorts, run `sudo port install curl-ca-bundle` in a terminal.
I've installed this project locally. How do I update it to the latest version?
:See [INSTALL.md](INSTALL.md)
How do I update my Python libraries to the latest versions, when using Anaconda?
:See [INSTALL.md](INSTALL.md)
## Contributors
I would like to thank everyone [who contributed to this project](https://github.com/ageron/handson-ml2/graphs/contributors), either by providing useful feedback, filing issues or submitting Pull Requests. Special thanks go to Haesun Park and Ian Beauregard who reviewed every notebook and submitted many PRs, including help on some of the exercise solutions. Thanks as well to Steven Bunkley and Ziembla who created the `docker` directory, and to github user SuperYorio who helped on some exercise solutions.