Run Jupyterq notebook with limit CPU cores

https://learninghub.kx.com/forums/topic/run-jupyterq-notebook-with-limit-cpu-cores

Hi guys, I try to use Jupyter kernel for kdb+ but meet following “License check failed” problem. I think this is because my non-commercial license has a constraint on max CPU cores.


When I directly run q in the command line, it raised “license error: cores” error. And “taskset -c 0-15 ~/q/l64/q” solves this issue. My question is: is there anyway I can limit my cpu cores when starting a KDB+ jupyter kernel, so that I can use q with jupyter notebook normally on my machine?


Thank you very much!


~$ ~/q/l64/q

KDB+ 4.1 2024.07.08 Copyright (C) 1993-2024 Kx Systems

l64/ 48(24)core 579514MB xxxx ubuntu-xxxxx-amd64-base xx.xx.xx.xx xxxxx@gmail.com KDB PLUS TRIAL #5020784

'license error: cores

~$ taskset -c 0-15 ~/q/l64/q

KDB+ 4.1 2024.07.08 Copyright (C) 1993-2024 Kx Systems

l64/ 16(24)core 579514MB xxxx ubuntu-xxxxx-amd64-base xx.xx.xx.xx xxxxx@gmail.com KDB PLUS TRIAL #5020784


q)



You could start Jupyter with a core restriction:

taskset -c 0-15 jupyter notebook 

Or see this answer I posted previously: (you could choose 0-15 rather than 0,1)

https://stackoverflow.com/a/77481466/4256419


Edit the file https://github.com/KxSystems/jupyterq/blob/master/kernelspec/kernel.json

``` { "argv": [ "taskset", "-c", "0,1", "q", "jupyterq_kernel.q", "-cds", "{connection_file}" ], "display_name": "Q (kdb+)", "language": "q", "env": {"JUPYTERQ_SERVERARGS":"","MPLBACKEND":"Agg"} }

<p>If you have already installed you can ensure Jupyter picks up the changes by reinstalling the kernel:</p>
python -m jupyter kernelspec install --user --name=qpk /path/to/kernelspec

Thank you rocuinneagain! I missed the naive answer? taskset is enough to solve my issue.