[SOLVED} Upgrading pytorch does not change which version Jupyter notebook uses

My pytorch was 0.3.1.post2, and it caused some problems to concatenation. I was advised to upgrade it. See Model parameters were cut off after concatenation

I upgraded it to a newer version 0.4.1.post2. Python command showed the upgrade was successful. However, my Jupyter notebook still used the old version 0.3.1.post2. Below are the details.

1. I cloned a new virtual environment where I used conda to do the pytorch upgrade:

conda install pytorch=0.4.1 -c pytorch

2. Discrepancy between the version testing results in the new virtual environment
I activated the new virtual environment, and running the following command line

python -c "import torch; print(torch.__version__)"

gave output: 0.4.1.post2

But in Jupyter notebook:

import torch

giving output: 0.3.1.post2

In case there was some stale configuration for Jupyter, I updated Jupyter by “conda update jupyter”. But that did not help.

Did I miss anything? Thanks.

Just found a solution …

Inside the web browser that shows the Jupyter window,

  1. select Kernel from the top menu
  2. select Change Kernel
  3. select the new kernel, in my case Python [conda env: new_env_name]