Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Docker stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JupyterLab
Python
Docker stack
Commits
6f723afd
Verified
Commit
6f723afd
authored
1 week ago
by
Olivier Benz
Browse files
Options
Downloads
Patches
Plain Diff
Update script 90-limits.sh
- Use command prlimit instead of ulimit - Add option to not limit address space
parent
ae3a6395
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
NOTES.md
+7
-5
7 additions, 5 deletions
NOTES.md
base/scripts/usr/local/bin/before-notebook.d/90-limits.sh
+14
-8
14 additions, 8 deletions
base/scripts/usr/local/bin/before-notebook.d/90-limits.sh
with
21 additions
and
13 deletions
NOTES.md
+
7
−
5
View file @
6f723afd
...
...
@@ -39,14 +39,16 @@ The following startup hooks are put in place:
*
[
/usr/local/bin/before-notebook.d/71-tensorboard.sh
](
base/scripts/usr/local/bin/before-notebook.d/71-tensorboard.sh
)
to use Jupyter Server Proxy for TensorBoard.
*
[
/usr/local/bin/before-notebook.d/90-limits.sh
](
base/scripts/usr/local/bin/before-notebook.d/90-limits.sh
)
*
*soft*
limit the
*address space*
based on the amount of
*physical*
and
*virtual memory*
of the host. (default: command
`ulimit -v`
)
*
*soft*
limit the
*address space*
based on the amount of
*physical memory*
(
`MEM_LIMIT`
) and
*virtual memory*
(
`SWAP_ENABLE`
,
`SWAP_FACTOR`
). (default:
command
`prlimit -v`
)
*
Do not limit if
`NO_AS_LIMIT`
or
`NO_MEM_LIMIT`
is set to
`1`
or
`yes`
.
*
limit the number of
*file descriptors*
according to environment variable
`NOFILE_LIMIT`
. (default: command
`
u
limit -n`
)
`NOFILE_LIMIT`
. (default: command
`
pr
limit -n`
)
*
limit the number of
*processes*
according to environment variable
`NPROC_LIMIT`
. (default: command
`
u
limit -u`
)
`NPROC_LIMIT`
. (default: command
`
pr
limit -u`
)
*
limit the number of
*pending signals*
according to environment variable
`SIGPEN_LIMIT`
. (default: command
`
u
limit -i`
)
`SIGPEN_LIMIT`
. (default: command
`
pr
limit -i`
)
*
[
/usr/local/bin/before-notebook.d/95-misc.sh
](
base/scripts/usr/local/bin/before-notebook.d/95-misc.sh
)
to export environment variables to
`/tmp/environment`
.
...
...
This diff is collapsed.
Click to expand it.
base/scripts/usr/local/bin/before-notebook.d/90-limits.sh
+
14
−
8
View file @
6f723afd
...
...
@@ -4,32 +4,38 @@
set
-e
DIVISOR
=
1024
if
[
"
$(
id
-u
)
"
!=
0
]
;
then
soft_limit
=
1
fi
if
[[
"
$SWAP_ENABLE
"
==
"1"
||
"
$SWAP_ENABLE
"
==
"yes"
]]
;
then
FACTOR
=
$(
echo
1
"
${
SWAP_FACTOR
:-
1
}
"
|
awk
'{ printf "%.1f", $1 + $2 }'
)
factor
=
$(
echo
1
"
${
SWAP_FACTOR
:-
1
}
"
|
awk
'{ printf "%.1f", $1 + $2 }'
)
else
FACTOR
=
1
factor
=
1
fi
# Limit address space: Soft when run as root and as other user
if
[
-n
"
$MEM_LIMIT
"
]
;
then
ulimit
-Sv
"
$(
echo
"
$MEM_LIMIT
"
"
$DIVISOR
"
"
$FACTOR
"
|
awk
'{ printf "%.0f", $1 / $2 * $3 }'
)
"
NO_AS_LIMIT
=
${
NO_AS_LIMIT
:-
$NO_MEM_LIMIT
}
# Do not limit if NO_AS_LIMIT or NO_MEM_LIMIT is set to 1 or yes
if
[[
"
$NO_AS_LIMIT
"
!=
"1"
&&
"
$NO_AS_LIMIT
"
!=
"yes"
]]
;
then
prlimit
--pid
$$
--as
=
"
$(
echo
"
$MEM_LIMIT
"
"
$factor
"
|
awk
'{ printf "%.0f", $1 * $2 }'
)
"
:
fi
fi
# Other limits: Hard when run as root user; Soft when run as other user
# pending signals
if
[
-n
"
$SIGPEN_LIMIT
"
]
;
then
u
limit
-
i
"
$(
printf
%.0f
"
$SIGPEN_LIMIT
"
)
"
pr
limit
-
-pid
$$
--sigpending
=
"
$(
printf
%.0f
"
$SIGPEN_LIMIT
"
)
"
${
soft_limit
:+:
}
fi
# file descriptors
if
[
-n
"
$NOFILE_LIMIT
"
]
;
then
u
limit
-
n
"
$(
printf
%.0f
"
$NOFILE_LIMIT
"
)
"
pr
limit
-
-pid
$$
--nofile
=
"
$(
printf
%.0f
"
$NOFILE_LIMIT
"
)
"
${
soft_limit
:+:
}
fi
# processes
if
[
-n
"
$NPROC_LIMIT
"
]
;
then
u
limit
-
u
"
$(
printf
%.0f
"
$NPROC_LIMIT
"
)
"
pr
limit
-
-pid
$$
--nproc
=
"
$(
printf
%.0f
"
$NPROC_LIMIT
"
)
"
${
soft_limit
:+:
}
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment