-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows Migration #219
base: main
Are you sure you want to change the base?
Windows Migration #219
Changes from 2 commits
ced0f05
2b70a4e
75fef38
5b3c151
00c6151
20387d8
95aab73
6063d2d
da2ce9c
3a10571
6e66558
8a9c5ca
f1d8fde
dfeca9e
c612127
7086a61
0cfc305
bb4aabf
5efb4f9
1f18a94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ py_binary( | |
requirement("wheel"), | ||
], | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Windows Migration | ||
|
||
Note that this merge request only intends to work on Windows. I haven't write code that switch support between linux and Windows. I'll update that feature after the whole thing can be build on Windows. | ||
|
||
## Setup Environment On Windows | ||
|
||
1. Install [Windows Powershell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.2). Do step 2 and 3 in Powershell. | ||
2. Install [choco](https://chocolatey.org/install#individual) | ||
3. Install bazelisk/bazel ``` choco install bazelisk``` | ||
4. Install [MinGW-w64](https://www.mingw-w64.org/) | ||
5. Install [git bash](https://gitforwindows.org/) and make sure it uses MINGW64 emulation. Do all the following steps in bash. | ||
6. Install [VC++ 2017](https://www.google.com/url?q=https://aka.ms/vs/15/release/vs_buildtools.exe&sa=D&source=docs&ust=1667504254128145&usg=AOvVaw3jOTmoHfuzAHgaScSgsmlE) on Windows | ||
7. Install python 3.10 (instead of 3.11 because pygame installation fails on Windows) | ||
8. Go where python.exe is installed, make a copy of python.exe and rename it python3.exe (it would bypass the bug "python interpreter cannot be found with requirement") | ||
9. Install [swig.exe](https://sourceforge.net/projects/swig/files/swigwin/swigwin-4.1.0/swigwin-4.1.0.zip/download?use_mirror=gigenet) and merge it into python folder and do [some hacks](https://stackoverflow.com/questions/44504899/installing-pocketsphinx-python-module-command-swig-exe-failed) | ||
10. Install [Clang](https://bazel.build/configure/windows#using) and follow this [link](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.2). Don't forget to set BAZEL_VC and BAZEL_LLVM in environmental variable manually. | ||
11. Now you can run some tests | ||
```bazel build --test_output=all //envpool/dummy:dummy_envpool_test --config=debug --compiler=clang-cl``` | ||
|
||
|
||
|
||
## Parts that built successfully | ||
- [x] Dummy | ||
- [x] Utils | ||
- [x] Box2d | ||
- [x] Classic Control | ||
- [x] Mujoco:mujoco_gym-env | ||
- [ ] Mujoco:mujoco_dmc_env: no matching function for call to 'mj_loadXML', use of undeclared identifier 'M_PI'... | ||
- [ ] Atari:atari_env #include <dlfcn.h> not found | ||
- [ ] Toy_text fatal error: 'cuda_runtime_api.h' file not found |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,14 +106,16 @@ class AsyncEnvPool : public EnvPool<typename Env::Spec> { | |
if (spec.config["thread_affinity_offset"_] >= 0) { | ||
std::size_t thread_affinity_offset = | ||
spec.config["thread_affinity_offset"_]; | ||
for (std::size_t tid = 0; tid < num_threads_; ++tid) { | ||
cpu_set_t cpuset; | ||
CPU_ZERO(&cpuset); | ||
std::size_t cid = (thread_affinity_offset + tid) % processor_count; | ||
CPU_SET(cid, &cpuset); | ||
pthread_setaffinity_np(workers_[tid].native_handle(), sizeof(cpu_set_t), | ||
&cpuset); | ||
} | ||
|
||
// The following does not work under Windows. Need to find alternatives. | ||
// for (std::size_t tid = 0; tid < num_threads_; ++tid) { | ||
// cpu_set_t cpuset; | ||
// CPU_ZERO(&cpuset); | ||
// std::size_t cid = (thread_affinity_offset + tid) % processor_count; | ||
// CPU_SET(cid, &cpuset); | ||
// pthread_setaffinity_np(workers_[tid].native_handle(), sizeof(cpu_set_t), | ||
// &cpuset); | ||
// } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,6 +18,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | |||||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||||||
load("//third_party/cuda:cuda.bzl", "cuda_configure") | ||||||
|
||||||
|
||||||
def workspace(): | ||||||
"""Load requested packages.""" | ||||||
maybe( | ||||||
|
@@ -318,13 +319,21 @@ def workspace(): | |||||
|
||||||
maybe( | ||||||
http_archive, | ||||||
name = "mujoco", | ||||||
name = "mujoco_linux", | ||||||
sha256 = "d1cb3a720546240d894cd315b7fd358a2b96013a1f59b6d718036eca6f6edac2", | ||||||
strip_prefix = "mujoco-2.2.1", | ||||||
urls = [ | ||||||
"https://github.com/deepmind/mujoco/releases/download/2.2.1/mujoco-2.2.1-linux-x86_64.tar.gz", | ||||||
"https://ml.cs.tsinghua.edu.cn/~jiayi/envpool/deepmind/mujoco/mujoco-2.2.1-linux-x86_64.tar.gz", | ||||||
], | ||||||
"https://github.com/deepmind/mujoco/releases/download/2.2.1/mujoco-2.2.1-linux-x86_64.tar.gz", | ||||||
"https://ml.cs.tsinghua.edu.cn/~jiayi/envpool/deepmind/mujoco/mujoco-2.2.1-linux-x86_64.tar.gz", | ||||||
], | ||||||
build_file = "//third_party/mujoco:mujoco.BUILD", | ||||||
) | ||||||
|
||||||
maybe( | ||||||
http_archive, | ||||||
name = "mujoco", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
sha256 = "e0068d25fdb00ec3afa53e429b5eff438d222455603bafa080086abaf11fe16f", | ||||||
urls = ["https://github.com/deepmind/mujoco/releases/download/2.2.1/mujoco-2.2.1-windows-x86_64.zip"], | ||||||
build_file = "//third_party/mujoco:mujoco.BUILD", | ||||||
) | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,9 @@ | |
_CUDA_DIR = "CUDA_DIR" | ||
|
||
def _impl(rctx): | ||
cuda_dir = rctx.os.environ.get(_CUDA_DIR, default = "/usr/local/cuda") | ||
rctx.symlink("{}/include".format(cuda_dir), "include") | ||
rctx.symlink("{}/lib64".format(cuda_dir), "lib64") | ||
cuda_dir = rctx.os.environ.get(_CUDA_DIR, default = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7") | ||
""" rctx.symlink("{}/include".format(cuda_dir), "include") | ||
rctx.symlink("{}/lib64".format(cuda_dir), "lib64") """ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use sth like |
||
rctx.file("WORKSPACE") | ||
rctx.file("BUILD", content = """ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure the best practice here, @mavenlin can you take a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember tensorflow use the same mechanism, but they have some fancy config script to detect cuda and generate the bazelrc.