Update to make find_rocm_config.py
to execute properly in RBE (remote build environment)
This commit is contained in:
parent
467bdaf578
commit
2dd9054636
37
third_party/gpus/compress_find_rocm_config.py
vendored
Normal file
37
third_party/gpus/compress_find_rocm_config.py
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""Compresses the contents of 'find_rocm_config.py'.
|
||||
|
||||
The compressed file is what is actually being used. It works around remote
|
||||
config not being able to upload files yet.
|
||||
"""
|
||||
import base64
|
||||
import zlib
|
||||
|
||||
|
||||
def main():
|
||||
with open('find_rocm_config.py', 'rb') as f:
|
||||
data = f.read()
|
||||
|
||||
compressed = zlib.compress(data)
|
||||
b64encoded = base64.b64encode(compressed)
|
||||
|
||||
with open('find_rocm_config.py.gz.base64', 'wb') as f:
|
||||
f.write(b64encoded)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
1
third_party/gpus/find_rocm_config.py.gz.base64
vendored
Normal file
1
third_party/gpus/find_rocm_config.py.gz.base64
vendored
Normal file
@ -0,0 +1 @@
|
||||
eJzNWm1v2zYQ/q5fQSgoKrWOkvbTkCEfvDRDvbVJYGcbhiYwaIm2ucqiRlJxjaL/fXckJUuynDh1gi5AUVu6e3i8e+5Fog/ImchXks/mmrw9fntMrueMXLNMCflrKpakX+i5kCoi/TQlQxRTZMgUk3csibwD74B84DGIs4QUWcIk0aDfz2kM/7k7PfInk4qLjLyNjkmA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GAhTcuwgCSJ0D8PUZSyCg/8gK2PKZ0Xx8AWyjoObj618LxWjuWf66+LC1+q1Z1mD6JsZT1r71om3Sa0ljcNZOvHeye1Pf4tTZb688A/Et8A/u/tfD/tn58An6fxuoNgEcrANUHcwIZl+pzSk8iFLH2NIVrv7Ws+d4ryzYwo6tidBgXiMXOpGeMh0aS7ffryh8qt7x9YqT3S8jKpz6SxZ75blaQrXAj8yMygh3Xv3x+9rCBsz39YU2zNW+jWE7PbpTok29xhuRTqQnS4n20i4lNl63t49HKEl4jKdTeD4opvbUyhiSMTzRdBvB1+jRA2dXHadk3ja6d+XkvYx/OapOHtdnjYbsVY000BXjN1ewVYspPGyEwHxbf/1kXwRrIdLPXBtp/7Z8vdw45Co1oiJPqGbBLucZ4RatXV4Eb9N96D3XNr0HXxXco3j/I9Y9ivdO5ffoPTTY3OPYhzpAWO8mBsIlzIJCVTdk1HJlOYmvmD+zVa885MqIElKzJNhMrgiSd6GCsKrg5ncBgf9CnZAXCk/+gjWSsd/9XqfGeDznYVZfrVRkf08Q4a9jWODfZOfD4eXwBOh7k91kfsl2pWUAgGGlBsmg8cjQ8yABx2M85RuPyekp8cdj3ON47J+Yuofb9f4Dez+DwA==
|
23
third_party/gpus/rocm_configure.bzl
vendored
23
third_party/gpus/rocm_configure.bzl
vendored
@ -383,7 +383,26 @@ def _find_libs(repository_ctx, rocm_config, bash_bin):
|
||||
|
||||
def _exec_find_rocm_config(repository_ctx, script_path):
|
||||
python_bin = get_python_bin(repository_ctx)
|
||||
return execute(repository_ctx, [python_bin, script_path])
|
||||
# If used with remote execution then repository_ctx.execute() can't
|
||||
# access files from the source tree. A trick is to read the contents
|
||||
# of the file in Starlark and embed them as part of the command. In
|
||||
# this case the trick is not sufficient as the find_cuda_config.py
|
||||
# script has more than 8192 characters. 8192 is the command length
|
||||
# limit of cmd.exe on Windows. Thus we additionally need to compress
|
||||
# the contents locally and decompress them as part of the execute().
|
||||
compressed_contents = repository_ctx.read(script_path)
|
||||
decompress_and_execute_cmd = (
|
||||
"from zlib import decompress;" +
|
||||
"from base64 import b64decode;" +
|
||||
"from os import system;" +
|
||||
"script = decompress(b64decode('%s'));" % compressed_contents +
|
||||
"f = open('script.py', 'wb');" +
|
||||
"f.write(script);" +
|
||||
"f.close();" +
|
||||
"system('\"%s\" script.py');" % (python_bin)
|
||||
)
|
||||
|
||||
return execute(repository_ctx, [python_bin, "-c", decompress_and_execute_cmd])
|
||||
|
||||
def find_rocm_config(repository_ctx, script_path):
|
||||
"""Returns ROCm config dictionary from running find_rocm_config.py"""
|
||||
@ -552,7 +571,7 @@ def _create_local_rocm_repository(repository_ctx):
|
||||
"rocm:rocm_config.h",
|
||||
]}
|
||||
|
||||
find_rocm_config_script = repository_ctx.path(Label("@org_tensorflow//third_party/gpus:find_rocm_config.py"))
|
||||
find_rocm_config_script = repository_ctx.path(Label("@org_tensorflow//third_party/gpus:find_rocm_config.py.gz.base64"))
|
||||
|
||||
bash_bin = get_bash_bin(repository_ctx)
|
||||
rocm_config = _get_rocm_config(repository_ctx, bash_bin, find_rocm_config_script)
|
||||
|
Loading…
Reference in New Issue
Block a user