jupyterhub / the-littlest-jupyterhub

Simple JupyterHub distribution for 1-100 users on a single server
https://tljh.jupyter.org
BSD 3-Clause "New" or "Revised" License
1.03k stars 339 forks source link

Document setting up and running Julia + Julia Kernel #279

Closed stegua closed 2 years ago

stegua commented 5 years ago

Is it possible to have Julia notebook in addition to Python3 notebook?

Otherwise: thanks a lot! I used your LittlestJupytherhub for an high school stage yesterday, and it worked very well. The only issue was that I did not set a memory limit per user, and a couple of users took all the memory, and I had to restart the server.

Thanks.

choldgraf commented 5 years ago

hmmm, good question...since you can conda install things, could you try installing julia with conda and see if that works? Not sure how you'd set this up without conda and pip though.

CagtayFabry commented 5 years ago

using conda, the following should work for a single user environment:

conda create -n julia_env -c conda-forge julia
source activate julia_env
julia # enter julia console

afterwards, inside the jula console to add the kernel:

ENV["JUPYTER"]="/opt/tljh/user/bin/jupyter"
using Pkg
Pkg.add("IJulia")

To make the environment available to all users, you will need some sudo commands when installing the environment and registering the kernel. Unfortunately the following didn't work for me (altered from installing R kernel). Maybe you can figure it out from here:

sudo -E conda create -n julia_env -c conda-forge julia
source activate julia_env
sudo -E julia # enter julia console and see above
yuvipanda commented 5 years ago

I think having a section in the docs dedicated to enabling Julia and R notebooks would be very useful!

josephc31415 commented 5 years ago

I have a JupyterHub up and running and performed the above steps for all users. The install seems to work but when I try to verify the Julia Kernel with println("Hello Julia.") the kernel seems to never produce a response in the Jupyter Notebook. Any ideas on how to trouble shoot this? Thanks

yuvipanda commented 5 years ago

@josephc31415 Looking at logs for the particular user (http://tljh.jupyter.org/en/latest/troubleshooting/logs.html#user-server-logs) might be useful!

AashitaK commented 5 years ago

Is there any update on the documentation for enabling IJulia on TLJH? I have been able to install and run Julia from the terminal for all users in my TLJH server, but could not find a way to enable Julia notebooks. I don't have much experience with Julia, so would greatly appreciate help in figuring this out. Thank you!

paulnakroshis commented 4 years ago

I agree that it would be great if a current Julia kernel was a standard feature in TLJH. Anyone recently have any success with an install that successfully integrated with both Jupyter Notebooks and Jupyter Lab?

AashitaK commented 4 years ago

@paulnakroshis: Yes, I am able to successfully run Julia Kernel with TLJH. I ran the following in the TLJH Terminal: jupyter-aashitak@servername:~$ sudo -E conda install -c conda-forge julia

Then, changed the permissions for the Julia folder: sudo -E chgrp -R adminjulia /home/jupyter-aashitak/.julia sudo -E chmod 770 -R /home/jupyter-aashitak/.julia sudo -E adduser jupyter-aashitak adminjulia

Finally, enabled the Julia notebooks: jupyter-aashitak@servername:~$ julia julia> using IJulia julia> notebook()

paulnakroshis commented 4 years ago

Did this enable julie in all TLJH users, or just your own account?

AashitaK commented 4 years ago

As I used "sudo -E", Julia is installed for all users. For enabling Julia kernel for notebooks, each user has to run the following in the TLJH Terminal: jupyter-username@servername:~$ julia julia> using Pkg julia> Pkg.add("IJulia")

The users need to run the above commands only once and the option for Julia kernels would show up every time they launch the server.

paulnakroshis commented 4 years ago

Thanks Aashita! I will try it out tomorrow!

-p


P a u l A. N a k r o s h i s
Associate Professor

Department of Physics 96 Falmouth Street, Portland, ME 04104 Office : 207. 780. 4158 Cell: 207.449.7531 FAX : 207. 228. 8288

Web Presence:

University site: people.usm.maine.edu/pauln/ Science Blog: www.paulnakroshis.net SciPyScriptRepo scipyscriptrepo.com Photography Blog: www.mainesight.com and Portfolio: www.paulandrewphoto.com twitter: @paulnakroshis


On Nov 5, 2019, at 10:38 PM, Aashita Kesarwani notifications@github.com wrote:

 As I used "sudo -E", Julia is installed for all users. For enabling Julia kernel for notebooks, each user has to run the following in the TLJH Terminal: jupyter-username@servername:~$ julia julia> using Pkg julia> Pkg.add("IJulia")

These commands need to run only once by each user and the option for Julia kernels would should up every time they launch the server.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

moe5k commented 4 years ago

At first thx to AashitaK! I just tried it out but had a few little probs so i will provide my way to get it work...

  1. Open Terminal out of TLJH as an TLJH-Admin:

    sudo -E conda install -c conda-forge julia
    sudo addgroup adminjulia
    sudo -E chgrp -R adminjulia /home/jupyter-myusername/.julia
    sudo -E chmod 770 -R /home/jupyter-myusername/.julia
    sudo -E adduser jupyter-myusername adminjulia
  2. Starting julia with sudo:

    sudo julia
    julia> using Pkg
    julia> Pkg.add("IJulia")
    julia> exit()
  3. Changing permissions again:

    sudo -E chgrp -R adminjulia /home/jupyter-myusername/.julia
    sudo -E chmod 770 -R /home/jupyter-myusername/.julia
  4. preparing the notebook:

    julia
    julia> using IJulia
    .....precompiling....
    julia> notebook()

    From this point i could start a julia-notebook from the webUI

  5. Every other user has to do the following steps ONCE in a TLJH-Terminal:

    julia
    julia> using Pkg
    julia> Pkg.add("IJulia")
    julia> exit()

    That works so far but i would really appreciate to save at least the step number 5 what every user must do before he can use Julia...

Have anybody an idea how get that to work?

moe

quantiota commented 4 years ago

after installing julia, all work perfectly except the julia icon which is not displaying in both jupyterlab and jupyterhub when connecting only as admin. Open the icon in a new browser return the error message : 500 : Internal Server Error

icon location /julia-1.0 jupyter-devbox@quantiota:~$ sudo find -name logo-64x64.png ./.local/share/jupyter/kernels/julia-1.0/logo-64x64.png ./.local/share/jupyter/kernels/ir/logo-64x64.png ./.julia/packages/IJulia/F1GUo/deps/logo-64x64.png

Seems to be a file permission issue.

bjornarfjelldal commented 4 years ago

Hi all! I have followed the steps above to get Julia running on my TLJH, however I am struggling with permission issues when not running as sudo. When trying to add packages either via terminal calling simply "julia", or by using the jupyterlab console for julia, I and the other users I have enabled Julia for get this;

julia julia> using Pkg julia> Pkg.add("CSV")

IOError: futime: operation not permitted (EPERM)

Stacktrace: [1] uv_error at ./libuv.jl:85 [inlined] [2] futime at ./filesystem.jl:143 [inlined] [3] touch(::String) at ./file.jl:407 [4] write_env_usage(::String) at /home/conda/feedstock_root/build_artifacts/julia_1548684429855/work/usr/share/julia/stdlib/v1.0/Pkg/src/Types.jl:424 [5] Pkg.Types.EnvCache(::Nothing) at /home/conda/feedstock_root/build_artifacts/julia_1548684429855/work/usr/share/julia/stdlib/v1.0/Pkg/src/Types.jl:306 [6] Type at /home/conda/feedstock_root/build_artifacts/julia_1548684429855/work/usr/share/julia/stdlib/v1.0/Pkg/src/Types.jl:285 [inlined] [7] Type at ./none:0 [inlined] [8] #add_or_develop#12 at /home/conda/feedstock_root/build_artifacts/julia_1548684429855/work/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:29 [inlined] [9] #add_or_develop at ./none:0 [inlined] [10] #add_or_develop#11 at /home/conda/feedstock_root/build_artifacts/julia_1548684429855/work/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:28 [inlined] [11] #add_or_develop at ./none:0 [inlined] [12] #add_or_develop#10 at /home/conda/feedstock_root/build_artifacts/julia_1548684429855/work/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:27 [inlined] [13] #add_or_develop at ./none:0 [inlined] [14] #add#18 at /home/conda/feedstock_root/build_artifacts/julia_1548684429855/work/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:69 [inlined] [15] add(::String) at /home/conda/feedstock_root/build_artifacts/julia_1548684429855/work/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:69

Running "sudo julia" from terminal however, solves it - but this will not work for users without sudo/admin access.

Any ideas?

Also as a side question not related, is it possible to install a newer version of Julia (i.e. 1.3.x) than conda's 1.0.3 without any trouble? In that case, what is the best practice?

christineleroy commented 3 years ago

Hello, So is there a documentation to have julia kernel in jupyterhub for all users authenticated?

Thanks in advance, Christine

mauro3 commented 3 years ago

I managed to get it running for all users, i.e. without them having to do any extra steps. It's documented here: https://github.com/mauro3/JupyterHubWithJulia

Note though that I'm not sure this is the "best" or even a "good" solution. But it seems to work from the little testing I did so far. One issue I'm not clear about is how it will interact with updating, in particular IJulia.

yuvipanda commented 3 years ago

Wow, that's awesome work @mauro3! Would love for you to post it on discourse.jupyter.org for other users to see.

mauro3 commented 3 years ago

Thanks! Feel free to post it. Although, there are some updates incoming (https://github.com/mauro3/JupyterHubWithJulia/issues/1), so maybe wait a few days to let the dust settle.

yuvipanda commented 3 years ago

Awesome, @mauro3. I'll wait :)

mauro3 commented 3 years ago

@yuvipanda I think the dust has settled.

kschuler commented 3 years ago

Hi everyone. I found it challenging to get Julia working as well, so I made a tljh-plugin that tells TLJH to use docker spawner to spin up jupyter/datascience-notebook containers for each users in the hub. In case it helps, here it is: https://github.com/pennchildlanglab/tljh-datascience

consideRatio commented 2 years ago

For reference to a related situation, but not the same.

I installed Julia in a Z2JH deployment that relies on Docker images but that also mounts user storage after having built the docker image, which means anything in /home/jovyan for example will be replaced.

Due to that, I needed to install the Julia kernel in a way that made it install outside the home directory. To do that, I did the following.

Perhaps a common trick for installing Julia in TLJH shared by installing it for environments in Z2JH would be to install the kernel once in a common directory, rather than installing it in the user home directories for each user?

As root, install Julia

# Install Julia itself (Julia part 1/2)
#
# NOTE: Needs to be followed up by installing the Julia kernel in a location not
#       overridden by mounting the user storage as done below when we are no
#       longer acting as root.
#
# Latest version at https://julialang.org/downloads/
#
ENV JULIA_VERSION 1.6.3
ENV JULIA_PATH /srv/julia
ENV JULIA_DEPOT_PATH ${JULIA_PATH}/pkg
ENV PATH $PATH:${JULIA_PATH}/bin
RUN mkdir -p ${JULIA_PATH} \
 && curl -sSL "https://julialang-s3.julialang.org/bin/linux/x64/${JULIA_VERSION%[.-]*}/julia-${JULIA_VERSION}-linux-x86_64.tar.gz" \
  | tar -xz -C ${JULIA_PATH} --strip-components 1 \
 && mkdir -p ${JULIA_DEPOT_PATH} \
 && chown ${NB_UID}:${NB_UID} ${JULIA_DEPOT_PATH}

As the user, install Julia kernel outside the home directory

# Install Julia kernel (Julia part 2/2)
#
# NOTE: If we are not not setting JUPYTER_DATA_DIR, the Julia kernel gets
#       installed in ~/.local/share/jupyter/kernels, and that folder may be
#       overridden by a home directory mount. This was found out by using
#       "jupyter kernelspec list" during debugging.
#
#       Julia's installkernel function relates to JUPYTER_DATA_DIR via logic
#       defined at https://github.com/JuliaLang/IJulia.jl/blob/cc2a9bf61a2515596b177339f9a3514de8c38573/deps/kspec.jl#L32-L37
#
#       NB_PYTHON_PREFIX is presumed to be /srv/conda/envs/notebook in this
#       case, which is defined in this specific Dockerfile's base image.
#
RUN export JUPYTER_DATA_DIR="$NB_PYTHON_PREFIX/share/jupyter" \
 && julia --eval 'using Pkg; Pkg.add("IJulia"); using IJulia; installkernel("Julia");' \
 && julia --eval 'using Pkg; Pkg.instantiate(); Pkg.resolve(); pkg"precompile"'
consideRatio commented 2 years ago

I'm closing this in favor of #728 for a centralized discussion.