Using an ITensors sysimage when starting the Julia REPL in VS Code?

Hi, I am using the library ITensors, which suggests on its website (Running ITensor and Julia Codes · ITensors.jl) to generate a sysimage for faster startup times

julia> using ITensors; ITensors.compile()

In a terminal, this can be loaded if I start julia with the extension

$ julia --sysimage ~/.julia/sysimages/sys_itensors.so

Question: I would like the Julia REPL in VS Code to automatically start Julia in this way, that is, using the ITensors sysimage. How do I do this?

Follow up question: I am using a Jupyter notebooks in VS Code with a Julia Kernel. How can I tell Kernel that it should load the ITensors sysimage when it starts?

1 Like

Have a look here. That’s how I start my VSCode Julia sessions.

Not sure about the Jupyter notebook question.

You need to add a custom kernel to Jupyter. Below will add a kernel called “julia_ITensors”

using IJulia
installkernel("julia_ITensors","--sysimage=~/.julia/sysimages/sys_itensors.so")

See: Installation · IJulia

Thanks. The custom kernal for Jupyter works great.

However, considering my original question. If I follow the advice by TI23XPRO, I need to first create a project environment, then build a custom sysimage that is saved in the same project folder and then VSC is supposed to automatically find it. However, if I don’t want to create an environment and a custom sysimage of this environment (which might also include other packages), how to I tell VSC to consider the sysimage sys_itensors.so in my .julia/sysimages folder?

add "--sysimage ~/.julia/sysimages/sys_itensors.so" as an argument per How to launch Julia with command-line arguments in VS Code? - #2 by BenPH

1 Like

Thanks @DrPapa and @TI36XPro . We are adding the information above to the ITensor docs.

Hi miles, I followed the instruction as mentioned above while get error:

The terminal process "C:\Users\swan\AppData\Local\Programs\Julia-1.9.3\bin\julia.exe '-i', '--banner=no', '--project=C:\Users\swan\.julia\environments\v1.9', '--sysimage ~/.julia/sysimages/sys_itensors.so', 'c:\Users\swan\.vscode\extensions\julialang.language-julia-1.54.2\scripts\terminalserver\terminalserver.jl', '\\.\pipe\vsc-jl-repl-33df9511-9f4e-42c8-a0e8-23f4a9e10148', '\\.\pipe\vsc-jl-cr-02a5deaf-bbd0-4c46-87d9-86cc652f3458', 'USE_REVISE=true', 'USE_PLOTPANE=true', 'USE_PROGRESS=true', 'ENABLE_SHELL_INTEGRATION=true', 'DEBUG_MODE=false'" terminated with exit code: 1.

I start REPL by ctrl+Shift+P and Julia: Start REPL.

Can you run that command from a terminal?

Good news! It works by changing the argument in "julia.additionalArgs" to "--sysimage=.\\.julia\\sysimages\\sys_itensors.so". (Windows system)

1 Like