jupytergoogle-ai-platformr-4.0.0

Cannot connect to R kernel using jupyter notebook instance on Google AI Platform


When I create a new instance following the directions here https://cloud.google.com/architecture/data-science-with-r-on-gcp-eda, the notebook cannot connect to the R kernel. It says initializing, then connecting then it disconnects.

When I SSH to the server and call curl http://127.0.0.1:8080/api/kernelspecs, I get the following output.

{
    "default": "python3", 
    "kernelspecs": {
        "python3": {
            "name": "python3", 
            "spec": {
                "argv": [
                    "/opt/conda/bin/python", "-m","ipykernel_launcher", "-f", "{connection_file}"
                ], 
                "env": {}, 
                "display_name": "Python 3", 
                "language": "python", 
                "interrupt_mode": "signal", 
                "metadata": {"debugger": true}
            }, 
            "resources": {
                "logo-32x32": "/kernelspecs/python3/logo-32x32.png",
                "logo-64x64": "/kernelspecs/python3/logo-64x64.png"
            }
        }, 
        "ir": {
            "name": "ir", 
            "spec": {
                "argv": [
                    "/usr/lib/R/bin/R", "--slave", "-e", "IRkernel::main()", "--args", "{connection_file}"
                ], 
                "env": {}, 
                "display_name": "R", 
                "language": "R", 
                "interrupt_mode": "signal", 
                "metadata": {}
            }, 
            "resources": {
                "kernel.js": "/kernelspecs/ir/kernel.js", 
                "logo-64x64": "/kernelspecs/ir/logo-64x64.png"}
            }, 
            "conda-root-py": {
                "name": "conda-root-py", 
                "spec": {
                    "argv": ["/opt/conda/bin/python", "-m", "ipykernel_launcher", "-f", "{connection_file}"
                    ], 
                    "env": {}, 
                    "display_name": 
                    "Python [conda env:root] *", 
                    "language": "python", 
                    "interrupt_mode": "signal", 
                    "metadata": {
                        "debugger": true, 
                        "conda_env_name": "root", 
                        "conda_env_path": "/opt/conda"
                    }
                }, 
                "resources": {
                    "logo-32x32": "/kernelspecs/conda-root-py/logo-32x32.png", 
                    "logo-64x64": "/kernelspecs/conda-root-py/logo-64x64.png"
                }
            }
       }
}root@r-ma5832xxxxxxxxx

Is this right for an instance that was created using the R4.0 environment option?


Solution

  • When I checked the server logs I found this:

    Error: package ‘IRkernel’ was installed before R 4.0.0: please re-install it
    

    I opened an ssh console to the server and cd'd to /etc/R, then started R by typing 'R'.

    I then tried to install the package using install.packages('IRkernel') as per instructions here: https://github.com/IRkernel/IRkernel only I ran into a whole lot of missing dependencies. I tried to update my version of R by following the instructions here: https://cran.r-project.org/bin/linux/debian/#debian-buster-stable but it turned out I was up to date. The only thing left was to update all my packages. I followed the instructions from the cran website and then went back to my jupyter notebook and could connect to the kernel.

    IN the end, all I had to do was run the command below in R on my server to unlock the kernel.

    update.packages(lib.loc="/usr/local/lib/R/site-library", ask = FALSE, checkBuilt = TRUE, Ncpus = 16)